black 20.8b1

This commit is contained in:
Inada Naoki
2020-12-04 12:21:41 +09:00
parent d7b988ae16
commit d56b0b7f8c
5 changed files with 43 additions and 35 deletions

View File

@ -131,7 +131,11 @@ def Time_or_None(s):
def Date_or_None(s): def Date_or_None(s):
try: try:
return date(int(s[:4]), int(s[5:7]), int(s[8:10]),) # year # month # day return date(
int(s[:4]),
int(s[5:7]),
int(s[8:10]),
) # year # month # day
except ValueError: except ValueError:
return None return None

View File

@ -68,12 +68,12 @@ class DatabaseTest(unittest.TestCase):
def create_table(self, columndefs): def create_table(self, columndefs):
""" Create a table using a list of column definitions given in """Create a table using a list of column definitions given in
columndefs. columndefs.
generator must be a function taking arguments (row_number, generator must be a function taking arguments (row_number,
col_number) returning a suitable data object for insertion col_number) returning a suitable data object for insertion
into the table. into the table.
""" """
self.table = self.new_table_name() self.table = self.new_table_name()

View File

@ -5,7 +5,10 @@ from os import environ, path
tests_path = path.dirname(__file__) tests_path = path.dirname(__file__)
conf_file = environ.get("TESTDB", "default.cnf") conf_file = environ.get("TESTDB", "default.cnf")
conf_path = path.join(tests_path, conf_file) conf_path = path.join(tests_path, conf_file)
connect_kwargs = dict(read_default_file=conf_path, read_default_group="MySQLdb-tests",) connect_kwargs = dict(
read_default_file=conf_path,
read_default_group="MySQLdb-tests",
)
def connection_kwargs(kwargs): def connection_kwargs(kwargs):

View File

@ -66,25 +66,25 @@ import time
class DatabaseAPI20Test(unittest.TestCase): class DatabaseAPI20Test(unittest.TestCase):
""" Test a database self.driver for DB API 2.0 compatibility. """Test a database self.driver for DB API 2.0 compatibility.
This implementation tests Gadfly, but the TestCase This implementation tests Gadfly, but the TestCase
is structured so that other self.drivers can subclass this is structured so that other self.drivers can subclass this
test case to ensure compiliance with the DB-API. It is test case to ensure compiliance with the DB-API. It is
expected that this TestCase may be expanded in the future expected that this TestCase may be expanded in the future
if ambiguities or edge conditions are discovered. if ambiguities or edge conditions are discovered.
The 'Optional Extensions' are not yet being tested. The 'Optional Extensions' are not yet being tested.
self.drivers should subclass this test, overriding setUp, tearDown, self.drivers should subclass this test, overriding setUp, tearDown,
self.driver, connect_args and connect_kw_args. Class specification self.driver, connect_args and connect_kw_args. Class specification
should be as follows: should be as follows:
import dbapi20 import dbapi20
class mytest(dbapi20.DatabaseAPI20Test): class mytest(dbapi20.DatabaseAPI20Test):
[...] [...]
Don't 'import DatabaseAPI20Test from dbapi20', or you will Don't 'import DatabaseAPI20Test from dbapi20', or you will
confuse the unit tester - just 'import dbapi20'. confuse the unit tester - just 'import dbapi20'.
""" """
# The self.driver module. This should be the module where the 'connect' # The self.driver module. This should be the module where the 'connect'
@ -110,15 +110,15 @@ class DatabaseAPI20Test(unittest.TestCase):
cursor.execute(self.ddl2) cursor.execute(self.ddl2)
def setUp(self): def setUp(self):
""" self.drivers should override this method to perform required setup """self.drivers should override this method to perform required setup
if any is necessary, such as creating the database. if any is necessary, such as creating the database.
""" """
pass pass
def tearDown(self): def tearDown(self):
""" self.drivers should override this method to perform required cleanup """self.drivers should override this method to perform required cleanup
if any is necessary, such as deleting the test database. if any is necessary, such as deleting the test database.
The default drops the tables that may be created. The default drops the tables that may be created.
""" """
con = self._connect() con = self._connect()
try: try:
@ -521,8 +521,8 @@ class DatabaseAPI20Test(unittest.TestCase):
] ]
def _populate(self): def _populate(self):
""" Return a list of sql commands to setup the DB for the fetch """Return a list of sql commands to setup the DB for the fetch
tests. tests.
""" """
populate = [ populate = [
"insert into {}booze values ('{}')".format(self.table_prefix, s) "insert into {}booze values ('{}')".format(self.table_prefix, s)
@ -710,9 +710,9 @@ class DatabaseAPI20Test(unittest.TestCase):
con.close() con.close()
def help_nextset_setUp(self, cur): def help_nextset_setUp(self, cur):
""" Should create a procedure called deleteme """Should create a procedure called deleteme
that returns two result sets, first the that returns two result sets, first the
number of rows in booze then "name from booze" number of rows in booze then "name from booze"
""" """
raise NotImplementedError("Helper not implemented") raise NotImplementedError("Helper not implemented")
# sql=""" # sql="""

View File

@ -161,9 +161,10 @@ class test_MySQLdb(dbapi20.DatabaseAPI20Test):
pass # performed in test_MySQL_capabilities pass # performed in test_MySQL_capabilities
def help_nextset_setUp(self, cur): def help_nextset_setUp(self, cur):
""" Should create a procedure called deleteme """
that returns two result sets, first the Should create a procedure called deleteme
number of rows in booze then "name from booze" that returns two result sets, first the
number of rows in booze then "name from booze"
""" """
sql = """ sql = """
create procedure deleteme() create procedure deleteme()