nose-devs / nose2

The successor to nose, based on unittest2
https://nose2.io
Other
795 stars 135 forks source link

Config files loaded from --top-level-directory, not --start-dir (as documented) #448

Open znewman01 opened 5 years ago

znewman01 commented 5 years ago

Per --help, the default config file location is "start directory":

$ nose2 --help
usage: nose2 [...]
[...]
  -s START_DIR, --start-dir START_DIR
                        Directory to start discovery ('.' default)
  -t TOP_LEVEL_DIRECTORY, --top-level-directory TOP_LEVEL_DIRECTORY, --project-directory TOP_LEVEL_DIRECTORY
                        Top level directory of project (defaults to start dir)
  --config [CONFIG], -c [CONFIG]
                        Config files to load, if they exist. ('unittest.cfg'
                        and 'nose2.cfg' in start directory default)
[...]
$

That doesn't square with my experience:

Minimal repro:

$ tree
.
├── nose2.cfg
└── tests
    ├── __init__.py
    └── test_nose.py

2 directories, 3 files
$ nose2  # works, as expected
$ cd tests
$ nose2  # fails, as expected
$ nose2 -s ../  # FAILS (unexpected) because `layers` plugin not installed
$ nose2 -t ../  # works
$ nose2 -t ../ -s ../  # works

Full log here

Unsolicited Opinion about how to resolve

(Related: #132)

Not sure if there's a grand plan here that I'm not aware of, but I'd just change

'unittest.cfg' and 'nose2.cfg' in start directory default)

to

'unittest.cfg' and 'nose2.cfg' in top-level directory default)

in the help text.

To me (a very casual new user) it seems to make a lot of sense that --top-level-directory would basically be like setting $PWD for the command and control the directory for most things, and --start-dir only controls where to look for tests (the name of the latter isn't very clear, to be honest).

sirosen commented 5 years ago

Thanks for the detailed report. I agree that the best short term fix is to clean up the documentation.

I don't want to break people's usage unnecessarily, so renaming the options should be done slowly -- introducing a new name and deprecating the old, etc. I've never really loved these option names myself. I think they're very confusing.

What about --work-dir and --test-dir as future names? Maybe -t should just be removed, and people can cd wherever they want to go... I'll have to examine it's exact effects to confirm that that's sufficient.

znewman01 commented 5 years ago

Stephen Rosen notifications@github.com writes:

Thanks for the detailed report. I agree that the best short term fix is to clean up the documentation. Thanks for the work on nose2!

I don't want to break people's usage unnecessarily, so renaming the options should be done slowly -- introducing a new name and deprecating the old, etc. I've never really loved these option names myself. I think they're very confusing. Oh, I know how that goes :)

What about --work-dir and --test-dir as future names? Maybe -t should just be removed, and people can cd wherever they want to go... I'll have to examine it's exact effects to confirm that that's sufficient. Those are much clearer names, especially --test-dir.

I would have no problem with removing -t. If it really just sets $PWD then I don't see a need. And if it does more than that, we should explain what.

My use case: I have a little Emacs code to run nose2 in the root of my current project. No problem for me to work around. In general, I'd guess --top-level-dir would be useful mostly for CI or editor integrations, and no big deal in either case.

If it does other important things, then you should completely ignore me :)