Isort: Not correctly detecting a module called `tests` as first-party

Created on 10 Aug 2015  路  5Comments  路  Source: PyCQA/isort

1) Clone https://github.com/mozilla/treeherder (revision 1c00ccf for reproducibility)
2) pip install -r requirements/common.txt -r requirements/dev.txt
3) isort --diff tests/e2e/conftest.py

Expected:
No diff shown (ie no changes required), since the tests module is local:
https://github.com/mozilla/treeherder/blob/1c00ccfcc74275f3ff7366c6150614bb065a8dc2/tests/__init__.py

Actual:

~/treeherder $ isort --diff tests/e2e/conftest.py
--- /home/vagrant/treeherder/tests/e2e/conftest.py:before       2015-08-10 18:10:55.381588
+++ /home/vagrant/treeherder/tests/e2e/conftest.py:after        2015-08-10 18:24:01.752271
@@ -7,8 +7,8 @@
 import pytest
 import simplejson as json
 from django.template import Context, Template
+from tests import test_utils

-from tests import test_utils
 from treeherder.client import TreeherderJobCollection

 base_dir = os.path.dirname(__file__)

To avoid this, I have to instead use:
isort --diff --project tests tests/e2e/conftest.py

Using isort 4.0.0 with Python 2.7.10 on Ubuntu 14.04.

bug

Most helpful comment

Sorry for the delayed response, but I've finally remembered to remove the known_first_party = tests workaround we'd added to setup.cfg and this still reproduces using isort 4.2.5.

ie:
1) Clone https://github.com/mozilla/treeherder (revision ab82e615 for reproducibility)
2) pip install -r requirements/common.txt -r requirements/dev.txt
3) Remove the known_first_party = tests line from setup.cfg
4) isort --diff tests/e2e/conftest.py

Expected:
isort succeeds.

Actual:

--- /home/vagrant/treeherder/tests/e2e/conftest.py:before       2017-04-10 15:52:01.741759
+++ /home/vagrant/treeherder/tests/e2e/conftest.py:after        2017-04-18 13:52:00.339980
@@ -4,8 +4,8 @@
 import simplejson as json
 from django.template import (Context,
                              Template)
+from tests import test_utils

-from tests import test_utils
 from treeherder.client.thclient import TreeherderJobCollection

 base_dir = os.path.dirname(__file__)

Could you reopen this issue?

Many thanks :-)

All 5 comments

I can reproduce this with isort 4.2.2 - is there any more information I can provide that would be useful? :-)

Sorry for the delay! Will look into this soon.

Thanks!

~Timothy

This has been resolved in develop and will make its way into the next release.

Thanks!

~Timothy

Many thanks :-)

Sorry for the delayed response, but I've finally remembered to remove the known_first_party = tests workaround we'd added to setup.cfg and this still reproduces using isort 4.2.5.

ie:
1) Clone https://github.com/mozilla/treeherder (revision ab82e615 for reproducibility)
2) pip install -r requirements/common.txt -r requirements/dev.txt
3) Remove the known_first_party = tests line from setup.cfg
4) isort --diff tests/e2e/conftest.py

Expected:
isort succeeds.

Actual:

--- /home/vagrant/treeherder/tests/e2e/conftest.py:before       2017-04-10 15:52:01.741759
+++ /home/vagrant/treeherder/tests/e2e/conftest.py:after        2017-04-18 13:52:00.339980
@@ -4,8 +4,8 @@
 import simplejson as json
 from django.template import (Context,
                              Template)
+from tests import test_utils

-from tests import test_utils
 from treeherder.client.thclient import TreeherderJobCollection

 base_dir = os.path.dirname(__file__)

Could you reopen this issue?

Many thanks :-)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

johnthagen picture johnthagen  路  3Comments

whg517 picture whg517  路  3Comments

pradyunsg picture pradyunsg  路  3Comments

AlexandreYang picture AlexandreYang  路  3Comments

jack1142 picture jack1142  路  3Comments