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

-w/--where does not preserve test selection by path #29

Open
jpellerin opened this issue Dec 14, 2011 · 2 comments
Open

-w/--where does not preserve test selection by path #29

jpellerin opened this issue Dec 14, 2011 · 2 comments
Assignees

Comments

@jpellerin
Copy link
Member

What steps will reproduce the problem?

  1. create a suite with a subdirectory like "tests" and a file like
    tests/test_foobar.py
  2. run $ nosetests --where=tests ./tests/test_foobar.py

What is the expected output? What do you see instead?

one would expect to have the test selected based on the file path but this
does not work since --where tells nose to chdir into the tests directory.

Workarounds :

This will work:
$ nosetests --where=tests test_foobar.py

The problem with that is you lose your shell's autocomplete ability :(

$ nosetests --where=tests tests.test_foobar

If you have init files that will work too. But again, no autocomplete.

Solving this might make working around issue116 easier (the non-import safe
problem)

Google Code Info:
Issue #: 189
Author: kumar.mcmillan
Created On: 2008-05-23T01:05:07.000Z
Closed On:

@ghost ghost assigned jpellerin Dec 14, 2011
@dfleury
Copy link

dfleury commented Aug 15, 2013

I'm having a problem for the same reason.
My team and I are working in a v2 of our project. We decided to leave the legacy apart, but working for while.
To continue using the django test command, we choose to create a new settings file which points to a custom test runner and define a set of arguments that nose should use.

settings_v2.py
TEST_RUNNER = 'runners.V2TestRunner'
NOSE_ARGS = [
    '--where=apps_v2',
]
Folder Hiercharchy Example
- MyProject/
  - my_django_project/
    + foo/
    + bar/
    + baz/
    - apps_v2/
      + new_app_1/
      + new_app_2/
    * settings_v2.py

Running the tests:

$ cd MyProject/my_django_project/
$ ./manage.py test settings=settings_v2

Unfortunately, on line 167 of nose's core.py, if --where is used, the directory will be changed to the one specified by the argument.

core.py@167
        if self.config.workingDir is not None:
            os.chdir(self.config.workingDir)

As a result, a third-party module looks for a folder which should exist at MyProject/my_django_project/, but this is not possible because nose has changed the location to MyProject/my_django_project/apps_v2/.

I tried to comment the lines 167,168 and all worked well. Tests were collected correctly and the working dir preserved. My third-party module is happy now.

I'm not sure if removing this lines is completely safe and I don't get why they exist. However, I think an argument to control this behavior, like --no-path-adjustment, should do.

@dfleury
Copy link

dfleury commented Aug 16, 2013

Can I make a patch with a --no-chdir argument?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants