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

python -m uniittest should work with file paths as well as test module names #54829

Closed
voidspace opened this issue Dec 4, 2010 · 2 comments
Closed
Assignees
Labels
stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@voidspace
Copy link
Contributor

BPO 10620
Nosy @merwok, @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 = 'https://github.com/voidspace'
closed_at = <Date 2011-01-03.18:19:56.210>
created_at = <Date 2010-12-04.00:20:06.349>
labels = ['type-bug', 'library']
title = '`python -m uniittest` should work with file paths as well as test module names'
updated_at = <Date 2011-01-03.18:19:56.209>
user = 'https://github.com/voidspace'

bugs.python.org fields:

activity = <Date 2011-01-03.18:19:56.209>
actor = 'michael.foord'
assignee = 'michael.foord'
closed = True
closed_date = <Date 2011-01-03.18:19:56.210>
closer = 'michael.foord'
components = ['Library (Lib)']
creation = <Date 2010-12-04.00:20:06.349>
creator = 'michael.foord'
dependencies = []
files = []
hgrepos = []
issue_num = 10620
keywords = []
message_count = 2.0
messages = ['123309', '123310']
nosy_count = 2.0
nosy_names = ['eric.araujo', 'michael.foord']
pr_nums = []
priority = 'normal'
resolution = 'fixed'
stage = 'resolved'
status = 'closed'
superseder = None
type = 'behavior'
url = 'https://bugs.python.org/issue10620'
versions = ['Python 3.2', 'Python 3.3']

@voidspace
Copy link
Contributor Author

Feature request against unittest2. Issue 18: https://code.google.com/p/unittest-ext/issues/detail?id=18

As providing a file path instead of module name to the unittest command line runner currently fails there is no backwards compatibility issue with making this work.

The only potential issue is if a test suite or module is genuinely 'foo.py' then we could end up attempting to load the file instead of the specified suite / module. To get round this we should only attempt to load tests from a file by checking the file exists first.

The specified still needs to be *imported* to load tests from it, so the file path will be converted to a module name by replacing path separators with '.'.

The way to execute test files that aren't importable as modules is to execute them directly not using python -m unittest.

@voidspace voidspace self-assigned this Dec 4, 2010
@voidspace voidspace added stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error labels Dec 4, 2010
@voidspace
Copy link
Contributor Author

Committed revision 87003.

@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
stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

1 participant