This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: unittest -h shows a flag -s but it doesn't work
Type: behavior Stage: resolved
Components: Tests Versions: Python 3.8
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: Faris Chugthai, eric.smith, serhiy.storchaka, xtreak
Priority: normal Keywords:

Created on 2020-07-09 04:37 by Faris Chugthai, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Messages (4)
msg373372 - (view) Author: Faris Chugthai (Faris Chugthai) Date: 2020-07-09 04:37
I'm not 100% sure what's happening here but running:

`python -m unittest -h`

shows a flag `-s` as does

`python -m unittest discover -h`.

When run as:

`python -m unittest discover -s test`

the command runs correctly but when run as

`python -m unittest -s test`

the command fails.

```sh

$ python -m unittest -s test  
                      
usage: python -m unittest [-h] [-v] [-q] [--locals] [-f]                                [-c] [-b] [-k TESTNAMEPATTERNS]                               [tests [tests ...]

       
python -m unittest: error: unrecognized arguments: -s

```

Which I believe to be a bug as the help generated by the discover subcommand indicates that the flag -s should be recognized.
msg373373 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2020-07-09 04:47
Where do you see option -s?
msg373376 - (view) Author: Karthikeyan Singaravelan (xtreak) * (Python committer) Date: 2020-07-09 05:05
The -s option shown in `python3 -m unittest -h` is grouped under help for discover. Options for a discover command don't necessarily apply to the unittest command itself.

$ python3 -m unittest -h
usage: python3 -m unittest [-h] [-v] [-q] [--locals] [-f] [-c] [-b]
                           [-k TESTNAMEPATTERNS]
                           [tests [tests ...]]

positional arguments:
  tests                a list of any number of test modules, classes and test
                       methods.

optional arguments:
  -h, --help           show this help message and exit
  -v, --verbose        Verbose output
  -q, --quiet          Quiet output
  --locals             Show local variables in tracebacks
  -f, --failfast       Stop on first fail or error
  -c, --catch          Catch Ctrl-C and display results so far
  -b, --buffer         Buffer stdout and stderr during tests
  -k TESTNAMEPATTERNS  Only run tests which match the given substring

Examples:
  python3 -m unittest test_module               - run tests from test_module
  python3 -m unittest module.TestClass          - run tests from module.TestClass
  python3 -m unittest module.Class.test_method  - run specified test method
  python3 -m unittest path/to/test_file.py      - run tests from test_file.py

usage: python3 -m unittest discover [-h] [-v] [-q] [--locals] [-f] [-c] [-b]
                                    [-k TESTNAMEPATTERNS] [-s START]
                                    [-p PATTERN] [-t TOP]

optional arguments:
  -h, --help            show this help message and exit
  -v, --verbose         Verbose output
  -q, --quiet           Quiet output
  --locals              Show local variables in tracebacks
  -f, --failfast        Stop on first fail or error
  -c, --catch           Catch Ctrl-C and display results so far
  -b, --buffer          Buffer stdout and stderr during tests
  -k TESTNAMEPATTERNS   Only run tests which match the given substring
  -s START, --start-directory START
                        Directory to start discovery ('.' default)
  -p PATTERN, --pattern PATTERN
                        Pattern to match tests ('test*.py' default)
  -t TOP, --top-level-directory TOP
                        Top level directory of project (defaults to start
                        directory)

For test discovery all test modules must be importable from the top level
directory of the project.
msg373484 - (view) Author: Eric V. Smith (eric.smith) * (Python committer) Date: 2020-07-10 21:13
This appears to just be a misunderstanding: -s is a flag to "unittest discover", not to "unittest" itself. I think this is clear from the help text, so I'm closing this.

If I'm incorrect, let me know.
History
Date User Action Args
2022-04-11 14:59:33adminsetgithub: 85425
2020-07-10 21:13:26eric.smithsetstatus: open -> closed

nosy: + eric.smith
messages: + msg373484

resolution: not a bug
stage: resolved
2020-07-09 05:05:09xtreaksetnosy: + xtreak
messages: + msg373376
2020-07-09 04:47:22serhiy.storchakasetnosy: + serhiy.storchaka
messages: + msg373373
2020-07-09 04:37:30Faris Chugthaicreate