Skip to content

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

Open
@znewman01

Description

@znewman01

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).

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions