Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[3.9] bpo-45500: Rewrite test_dbm (GH-29002)#29074

Merged
corona10 merged 1 commit into
python:3.9python/cpython:3.9from
ambv:backport-975b94b-3.9ambv/cpython:backport-975b94b-3.9Copy head branch name to clipboard
Oct 20, 2021
Merged

[3.9] bpo-45500: Rewrite test_dbm (GH-29002)#29074
corona10 merged 1 commit into
python:3.9python/cpython:3.9from
ambv:backport-975b94b-3.9ambv/cpython:backport-975b94b-3.9Copy head branch name to clipboard

Conversation

@ambv

@ambv ambv commented Oct 19, 2021

Copy link
Copy Markdown
Contributor
  • 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

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 have test.support.os_helper and test.support.import_helper so the imports are different for that.

https://bugs.python.org/issue45500

* 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>
@corona10

Copy link
Copy Markdown
Member

I reopen this PR due to bot staling.

Comment thread Lib/test/test_dbm.py
setup_test_dir()
dbm._defaultmod = module
# Try with empty files first
with module.open(_fname, 'c'): pass

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

diff

fnames = [_fname, os_helper.FakePath(_fname),
_bytes_fname, os_helper.FakePath(_bytes_fname)]
for module in dbm_iterator():

Copy link
Copy Markdown
Contributor Author

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.

Comment thread Lib/test/test_dbm.py
ndbm = None

_fname = test.support.TESTFN
dirname = test.support.TESTFN

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

diff

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)

@corona10 corona10 merged commit d46b221 into python:3.9 Oct 20, 2021
@ambv

ambv commented Oct 20, 2021

Copy link
Copy Markdown
Contributor Author

Thanks for taking care of this, @corona10!

@ambv ambv deleted the backport-975b94b-3.9 branch October 20, 2021 11:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

skip news tests Tests in the Lib/test dir

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.