Skip to content
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

regrtest checks (os.environ, sys.path, etc.) are hard to use #56523

Closed
merwok opened this issue Jun 10, 2011 · 9 comments
Closed

regrtest checks (os.environ, sys.path, etc.) are hard to use #56523

merwok opened this issue Jun 10, 2011 · 9 comments
Labels
tests Tests in the Lib/test dir type-feature A feature request or enhancement

Comments

@merwok
Copy link
Member

merwok commented Jun 10, 2011

BPO 12314
Nosy @vstinner, @ezio-melotti, @merwok, @bitdancer, @voidspace

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = None
closed_at = <Date 2015-10-02.21:24:02.741>
created_at = <Date 2011-06-10.16:19:09.319>
labels = ['type-feature', 'tests']
title = 'regrtest checks (os.environ, sys.path, etc.) are hard to use'
updated_at = <Date 2015-10-02.21:24:02.740>
user = 'https://github.com/merwok'

bugs.python.org fields:

activity = <Date 2015-10-02.21:24:02.740>
actor = 'vstinner'
assignee = 'none'
closed = True
closed_date = <Date 2015-10-02.21:24:02.741>
closer = 'vstinner'
components = ['Tests']
creation = <Date 2011-06-10.16:19:09.319>
creator = 'eric.araujo'
dependencies = []
files = []
hgrepos = []
issue_num = 12314
keywords = []
message_count = 9.0
messages = ['138101', '138109', '138110', '138378', '138381', '138673', '144276', '145110', '220508']
nosy_count = 7.0
nosy_names = ['vstinner', 'ezio.melotti', 'eric.araujo', 'r.david.murray', 'michael.foord', 'BreamoreBoy', 'python-dev']
pr_nums = []
priority = 'normal'
resolution = 'out of date'
stage = 'needs patch'
status = 'closed'
superseder = None
type = 'enhancement'
url = 'https://bugs.python.org/issue12314'
versions = ['Python 3.3']

@merwok
Copy link
Member Author

merwok commented Jun 10, 2011

When regrtest tells me that os.environ was modified by test_packaging, it’s very hard to find which test is responsible. The -vv output is hard to read: it prints four dictionaries, which I have to visually delineate, copy, paste, pretty-print and diff to find what’s changed. Then I edit the source code of regrtest so that it fails earlier, or I add a debug print in the packaging.util code that touches os.environ.

I’d like regrtest to tell me what exactly was changed, and where. For the first request, I think each checked object could use a type-specific method, for example _compare_dict would see if any value was changed and if keys are different, and print only that info.

@merwok merwok added the tests Tests in the Lib/test dir label Jun 10, 2011
@bitdancer
Copy link
Member

Improvements are welcome, the whole thing was a QnD hack that has been evolving over time...maybe there's some way to reuse unittest's assertEqual machinery?

I also wonder if the whole environment-changed thing should be moved into unittest so it could wrap around individual test methods.

@bitdancer bitdancer added the type-feature A feature request or enhancement label Jun 10, 2011
@merwok
Copy link
Member Author

merwok commented Jun 10, 2011

maybe there's some way to reuse unittest's assertEqual machinery?
Hum, I think the diff functionality is cleanly separated in a (private) method, so we could get diff for free.

I also wonder if the whole environment-changed thing should be moved
into unittest so it could wrap around individual test methods.
Yeah, I was thinking about a WatchfulTestRunner that would perform the same checks. It annoys me to have two diverging sets of features to run tests: either checks with regrtest, or failfast, discovery and granularity with unittest.

@voidspace
Copy link
Contributor

I don't think this is something that belongs in unittest - it's not something particularly useful (or at least particularly requested) outside of the python test suite. No reason that a WatchfulTestRunner couldn't live in regrtest.

@bitdancer
Copy link
Member

Sounds like a plan.

@vstinner
Copy link
Member

I’d like regrtest to tell me what exactly was changed, and where.

regrtests has many tests (you give some examples: os.environ, sys.path), run all tests after calling a single test function would make regrtest slower. We can add an option (e.g. --strict?) to run these sanity tests after calling a single test function.

I would also be nice to have this option for the refleak checks: run refleak checks on each function, instead of doing the checks on the whole file.

@python-dev
Copy link
Mannequin

python-dev mannequin commented Sep 19, 2011

New changeset 9c61f46ea6b4 by Éric Araujo in branch 'default':
Make regrtest look at internal dicts in sysconfig.
http://hg.python.org/cpython/rev/9c61f46ea6b4

@merwok
Copy link
Member Author

merwok commented Oct 7, 2011

Idea: when a regrtest check fails, the test is run again but a WatchfulMixin is injected into the test case’s bases, so that setUp and tearDown call the right methods. This would be more efficient than always running with a watchful test runner.

@BreamoreBoy
Copy link
Mannequin

BreamoreBoy mannequin commented Jun 13, 2014

@Éric do you intend following up on this?

@vstinner vstinner closed this as completed Oct 2, 2015
@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tests Tests in the Lib/test dir type-feature A feature request or enhancement
Projects
None yet
Development

No branches or pull requests

4 participants