@@ -84,7 +84,6 @@ def fifth(x):
84
84
def sixth(x):
85
85
return 6 * x
86
86
""" )
87
- # The setup.py to install everything.
88
87
make_file ("another_pkg/setup.py" , """\
89
88
import setuptools
90
89
setuptools.setup(
@@ -93,9 +92,52 @@ def sixth(x):
93
92
)
94
93
""" )
95
94
95
+ # Bug888 code.
96
+ make_file ("bug888/app/setup.py" , """\
97
+ from setuptools import setup
98
+ setup(
99
+ name='testcov',
100
+ packages=['testcov'],
101
+ namespace_packages=['testcov'],
102
+ )
103
+ """ )
104
+ make_file ("bug888/app/testcov/__init__.py" , """\
105
+ try: # pragma: no cover
106
+ __import__('pkg_resources').declare_namespace(__name__)
107
+ except ImportError: # pragma: no cover
108
+ from pkgutil import extend_path
109
+ __path__ = extend_path(__path__, __name__)
110
+ """ )
111
+ make_file ("bug888/app/testcov/main.py" , """\
112
+ import pkg_resources
113
+ for entry_point in pkg_resources.iter_entry_points('plugins'):
114
+ entry_point.load()()
115
+ """ )
116
+ make_file ("bug888/plugin/setup.py" , """\
117
+ from setuptools import setup
118
+ setup(
119
+ name='testcov-plugin',
120
+ packages=['testcov'],
121
+ namespace_packages=['testcov'],
122
+ entry_points={'plugins': ['testp = testcov.plugin:testp']},
123
+ )
124
+ """ )
125
+ make_file ("bug888/plugin/testcov/__init__.py" , """\
126
+ try: # pragma: no cover
127
+ __import__('pkg_resources').declare_namespace(__name__)
128
+ except ImportError: # pragma: no cover
129
+ from pkgutil import extend_path
130
+ __path__ = extend_path(__path__, __name__)
131
+ """ )
132
+ make_file ("bug888/plugin/testcov/plugin.py" , """\
133
+ def testp():
134
+ print("Plugin here")
135
+ """ )
136
+
96
137
# Install the third-party packages.
97
138
run_in_venv ("python -m pip install --no-index ./third_pkg" )
98
139
run_in_venv ("python -m pip install --no-index -e ./another_pkg" )
140
+ run_in_venv ("python -m pip install --no-index -e ./bug888/app -e ./bug888/plugin" )
99
141
shutil .rmtree ("third_pkg" )
100
142
101
143
# Install coverage.
@@ -141,7 +183,7 @@ def in_venv_world_fixture(self, venv_world):
141
183
yield
142
184
143
185
for fname in os .listdir ("." ):
144
- if fname not in {"venv" , "another_pkg" }:
186
+ if fname not in {"venv" , "another_pkg" , "bug888" }:
145
187
os .remove (fname )
146
188
147
189
def get_trace_output (self ):
@@ -274,3 +316,11 @@ def test_installed_namespace_packages(self, coverage_command):
274
316
assert "colorsys" not in out
275
317
assert "fifth" in out
276
318
assert "sixth" in out
319
+
320
+ def test_bug888 (self , coverage_command ):
321
+ out = run_in_venv (
322
+ coverage_command +
323
+ " run --source=bug888/app,bug888/plugin bug888/app/testcov/main.py"
324
+ )
325
+ # When the test fails, the output includes "Already imported a file that will be measured"
326
+ assert out == "Plugin here\n "
0 commit comments