-
-
Notifications
You must be signed in to change notification settings - Fork 32.1k
[3.9] bpo-45500: Rewrite test_dbm (GH-29002) #29074
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
* Generate test classes at import time. It allows to filter them when run with unittest. E.g: "./python -m unittest test.test_dbm.TestCase_gnu -v". * Create a database class in a new directory which will be removed after test. It guarantees that all created files and directories be removed and will not conflict with other dbm tests. * Restore dbm._defaultmod after tests. Previously it was set to the last dbm module (dbm.dumb) which affected other tests. * Enable the whichdb test for dbm.dumb. * Move test_keys to the correct test class. It does not test whichdb(). * Remove some outdated code and comments.. (cherry picked from commit 975b94b) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
I reopen this PR due to bot staling. |
setup_test_dir() | ||
dbm._defaultmod = module | ||
# Try with empty files first | ||
with module.open(_fname, 'c'): pass |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
diff
Lines 169 to 171 in a106343
fnames = [_fname, os_helper.FakePath(_fname), | |
_bytes_fname, os_helper.FakePath(_bytes_fname)] | |
for module in dbm_iterator(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, the difference is noted in the PR description.
try: | ||
from dbm import ndbm | ||
except ImportError: | ||
ndbm = None | ||
|
||
_fname = test.support.TESTFN | ||
dirname = test.support.TESTFN |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
diff
Lines 6 to 15 in a106343
from test.support import import_helper | |
from test.support import os_helper | |
try: | |
from dbm import ndbm | |
except ImportError: | |
ndbm = None | |
dirname = os_helper.TESTFN | |
_fname = os.path.join(dirname, os_helper.TESTFN) |
Thanks for taking care of this, @corona10! |
run with unittest. E.g: "./python -m unittest test.test_dbm.TestCase_gnu -v".
test. It guarantees that all created files and directories be removed
and will not conflict with other dbm tests.
dbm module (dbm.dumb) which affected other tests.
(cherry picked from commit 975b94b)
Co-authored-by: Serhiy Storchaka storchaka@gmail.com
NOTE: this is a little different from GH-29002 because 3.9 doesn't have support for
bytes
filenames and os.PathLike paths (only added in GH-21849). It also doesn't havetest.support.os_helper
andtest.support.import_helper
so the imports are different for that.https://bugs.python.org/issue45500