Skip to content

Add new testdirs ini option #823

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

Merged
merged 1 commit into from
Jul 11, 2015

Conversation

nicoddemus
Copy link
Member

As discussed in #694, but not exactly as described in there. Usually projects have a well defined location for tests (pytest for example is testing), so an option to specify which directories to look for tests when executing pytest without arguments from the root directory seems useful.

@hpk42
Copy link
Contributor

hpk42 commented Jul 9, 2015

Looks good, just one consideration: We might consider specifying wildcarded paths in the future such as "tests//test*.py or "app//tests/test*.py" in which case it might be better to name the ini option "testpaths" instead of "testdirs".

[pytest]
norecursedirs = .svn _build tmp*

This would tell ``pytest`` to not look into typical subversion or
sphinx-build directories or into any ``tmp`` prefixed directory.

.. confval:: testdirs

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check if we can add .. versionadded:: here

@nicoddemus
Copy link
Member Author

it might be better to name the ini option "testpaths"

Good point, I will change it later. 😄

@nicoddemus
Copy link
Member Author

@hpk42 changed to testpaths and added a "versionadded" directive to the documentation.

@nicoddemus nicoddemus force-pushed the testdirs-option branch 2 times, most recently from a09affe to aef416c Compare July 9, 2015 23:48
if os.getcwd() == self.rootdir:
args = self.getini('testpaths')
if not args:
args = [os.getcwd()]
self.args = args
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor nit. os.getcwd() should be assigned to a var and then this var used instead of potentially calling it twice IMHO.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True, done.

@nicoddemus nicoddemus force-pushed the testdirs-option branch 2 times, most recently from c37310e to 870f6fa Compare July 10, 2015 21:03
@nicoddemus
Copy link
Member Author

Rebased on master to account for the mock fix for py26.

nicoddemus added a commit that referenced this pull request Jul 11, 2015
@nicoddemus nicoddemus merged commit 40ec0ec into pytest-dev:master Jul 11, 2015
@nicoddemus nicoddemus deleted the testdirs-option branch July 11, 2015 16:50
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

Successfully merging this pull request may close these issues.

2 participants