diff --git a/noxfile.py b/noxfile.py index 569650a335..b2d42a5174 100644 --- a/noxfile.py +++ b/noxfile.py @@ -87,7 +87,7 @@ def default(session): "--cov-append", "--cov-config=.coveragerc", "--cov-report=", - "--cov-fail-under=65", + "--cov-fail-under=80", os.path.join("tests", "unit"), *session.posargs, ) @@ -157,7 +157,7 @@ def cover(session): test runs (not system test runs), and then erases coverage data. """ session.install("coverage", "pytest-cov") - session.run("coverage", "report", "--show-missing", "--fail-under=65") + session.run("coverage", "report", "--show-missing", "--fail-under=80") session.run("coverage", "erase") diff --git a/tests/unit/django_spanner/test_operations.py b/tests/unit/django_spanner/test_operations.py index 9bed6a447e..a946b51303 100644 --- a/tests/unit/django_spanner/test_operations.py +++ b/tests/unit/django_spanner/test_operations.py @@ -4,10 +4,15 @@ # license that can be found in the LICENSE file or at # https://developers.google.com/open-source/licenses/bsd -from django.db.utils import DatabaseError +from base64 import b64encode from datetime import timedelta -from tests.unit.django_spanner.simple_test import SpannerSimpleTestClass from decimal import Decimal +from django.conf import settings +from django.core.management.color import no_style +from django.db.utils import DatabaseError +from google.cloud.spanner_dbapi.types import DateStr +from tests.unit.django_spanner.simple_test import SpannerSimpleTestClass +import uuid class TestOperations(SpannerSimpleTestClass): @@ -29,8 +34,6 @@ def test_bulk_batch_size(self): ) def test_sql_flush(self): - from django.core.management.color import no_style - self.assertEqual( self.db_operations.sql_flush( style=no_style(), tables=["Table1", "Table2"] @@ -39,15 +42,11 @@ def test_sql_flush(self): ) def test_sql_flush_empty_table_list(self): - from django.core.management.color import no_style - self.assertEqual( self.db_operations.sql_flush(style=no_style(), tables=[]), [], ) def test_adapt_datefield_value(self): - from google.cloud.spanner_dbapi.types import DateStr - self.assertIsInstance( self.db_operations.adapt_datefield_value("dummy_date"), DateStr, ) @@ -69,8 +68,6 @@ def test_adapt_decimalfield_value_none(self): ) def test_convert_binaryfield_value(self): - from base64 import b64encode - self.assertEqual( self.db_operations.convert_binaryfield_value( value=b64encode(b"abc"), expression=None, connection=None @@ -96,8 +93,6 @@ def test_adapt_timefield_value_none(self): ) def test_convert_uuidfield_value(self): - import uuid - uuid_obj = uuid.uuid4() self.assertEqual( self.db_operations.convert_uuidfield_value( @@ -126,8 +121,6 @@ def test_date_extract_sql_lookup_type_dayofweek(self): ) def test_datetime_extract_sql(self): - from django.conf import settings - settings.USE_TZ = True self.assertEqual( self.db_operations.datetime_extract_sql( @@ -137,8 +130,6 @@ def test_datetime_extract_sql(self): ) def test_datetime_extract_sql_use_tz_false(self): - from django.conf import settings - settings.USE_TZ = False self.assertEqual( self.db_operations.datetime_extract_sql( @@ -167,8 +158,6 @@ def test_datetime_cast_date_sql(self): ) def test_datetime_cast_time_sql(self): - from django.conf import settings - settings.USE_TZ = True self.assertEqual( self.db_operations.datetime_cast_time_sql("dummy_field", "IST"), @@ -176,8 +165,6 @@ def test_datetime_cast_time_sql(self): ) def test_datetime_cast_time_sql_use_tz_false(self): - from django.conf import settings - settings.USE_TZ = False self.assertEqual( self.db_operations.datetime_cast_time_sql("dummy_field", "IST"),