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

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

Open
znewman01 opened this issue Aug 29, 2019 · 2 comments
Assignees

Comments

@znewman01
Copy link

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.cfg:

    [unittest]
    plugins = nose2.plugins.layers
    
  • test/test_nose.py

    import unittest
    
    class DemoLayer:
        @classmethod
        def setUp(cls):
            unittest.MONKEY_PATCH = True
    
    class NoseTests(unittest.TestCase):
        layer = DemoLayer
        def test_needs_setup(self):
            self.assertTrue(unittest.MONKEY_PATCH)
    
  • test/__init__.py: empty

$ 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
Copy link
Collaborator

sirosen commented Sep 14, 2019

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
Copy link
Author

znewman01 commented Sep 15, 2019 via email

@sirosen sirosen self-assigned this Dec 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants