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

Add globbing to codestyle_exclude #43

Merged
merged 1 commit into from
Nov 22, 2018

Conversation

TLATER
Copy link
Contributor

@TLATER TLATER commented Nov 8, 2018

This "works", but it doesn't quite satisfy test cases. Since I'm not
sure what this test case wants to assert, I'm a little stuck here.

@henry0312 henry0312 self-requested a review November 15, 2018 06:32
@henry0312 henry0312 self-assigned this Nov 15, 2018
@henry0312
Copy link
Owner

Hello, @TLATER,
I'm sorry for late response.
I don't have much time to review, but I will check #42 and #43 by this weekend.

@henry0312
Copy link
Owner

This change will fix tests:

diff --git a/test_pytest_codestyle.py b/test_pytest_codestyle.py
--- a/test_pytest_codestyle.py
+++ b/test_pytest_codestyle.py
@@ -46,9 +46,9 @@ def test_ini(testdir):
             ignore = ['d', 'e', 'f']
             assert config.getini('codestyle_ignore') == ignore
             assert config.getini('codestyle_show_source') is True
-            exclude = ['{dirname}/{base}/exclude.py', '{dirname}/{base}/path/to/another/exclude.py']
+            exclude = ['exclude.py', 'path/to/another/exclude.py']
             assert config.getini('codestyle_exclude') == exclude
-    """.format(dirname=testdir.tmpdir.dirname, base=testdir.tmpdir.basename))
+    """)
     p = p.write(p.read() + "\n")
     result = testdir.runpytest('--codestyle')
     result.assert_outcomes(passed=2)

This is because of pathlist of pytest.

@henry0312
Copy link
Owner

And please update test_pytest_collect_file_with_exclude like this:

diff --git a/test_pytest_codestyle.py b/test_pytest_codestyle.py
--- a/test_pytest_codestyle.py
+++ b/test_pytest_codestyle.py
@@ -65,13 +65,14 @@ def test_pytest_collect_file(testdir):
 def test_pytest_collect_file_with_exclude(testdir):
     testdir.makeini("""
         [pytest]
-        codestyle_exclude = a.py path/to/c.py
+        codestyle_exclude = a.py path/**/?.py
     """)
     testdir.tmpdir.ensure('a.py')
     testdir.tmpdir.ensure('b.py')
     testdir.tmpdir.ensure('path/to/c.py')
+    testdir.tmpdir.ensure('path/to/hoge/foo.py')
     result = testdir.runpytest('--codestyle')
-    result.assert_outcomes(passed=1)
+    result.assert_outcomes(passed=2)


 def test_cache(testdir):

This will add a test case.

Copy link
Owner

@henry0312 henry0312 left a comment

Choose a reason for hiding this comment

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

pytest_codestyle.py Outdated Show resolved Hide resolved
@TLATER TLATER force-pushed the tlater/globbing branch 4 times, most recently from f7a92db to de0a256 Compare November 21, 2018 14:58
Sometimes a specific directory might include files that follow
different style conventions (e.g., code generated using grpc) - before
this change, any such files would need to be excluded individually.

This commit makes specifying excluded files more flexible by allowing
globbing in file paths.

codestyle_exclude will now accept paths like `embedded_lib/**/*.py`,
which will match any file in any subdirectory of `embedded_lib` that
has a `.py` extension.
@TLATER
Copy link
Contributor Author

TLATER commented Nov 21, 2018

Thanks for the review @henry0312 - sorry it took me so long to respond as well ;)

I've simply applied the changes you suggested, is that enough for a merge in your eyes?

@henry0312 henry0312 changed the title WIP: Add globbing to codestyle_exclude Add globbing to codestyle_exclude Nov 22, 2018
Copy link
Owner

@henry0312 henry0312 left a comment

Choose a reason for hiding this comment

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

good work!

@henry0312 henry0312 merged commit 8383954 into henry0312:master Nov 22, 2018
@TLATER TLATER deleted the tlater/globbing branch November 23, 2018 00:48
@lockwooddev
Copy link

Will there be a new release for this change?

@henry0312
Copy link
Owner

I want to release a new version, but I've waited for #47.

henry0312 added a commit to henry0312/pytest-pydocstyle that referenced this pull request Dec 16, 2018
henry0312 added a commit to henry0312/pytest-pydocstyle that referenced this pull request Dec 16, 2018
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.

3 participants