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

Fix a test that only passed due to test interactions #443

Merged
merged 4 commits into from
Jul 28, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 18 additions & 7 deletions envisage/tests/test_egg_basket_plugin_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,19 @@ class EggBasketPluginManagerTestCase(unittest.TestCase):
def setUp(self):
""" Prepares the test fixture before each test method is called. """

# Some tests cause sys.path to be modified. Capture the original
# contents so that we can restore sys.path later.
self._original_sys_path_contents = sys.path[:]

# The location of the 'eggs' test data directory.
self.eggs_dir = join(dirname(__file__), "eggs")
self.bad_eggs_dir = join(dirname(__file__), "bad_eggs")

def tearDown(self):
""" Called immediately after each test method has been called. """
# Undo any side-effects: egg_basket_plugin_manager modifies sys.path.
sys_path = []
for path in sys.path:
if self.bad_eggs_dir not in path:
sys_path.append(path)
sys.path = sys_path

# Undo any sys.path modifications
sys.path[:] = self._original_sys_path_contents

# `envisage.egg_utils.get_entry_points_in_egg_order` modifies the
# global working set.
Expand Down Expand Up @@ -174,16 +175,26 @@ def on_broken_plugin(ep, exc):
self.assertTrue(isinstance(exc, ImportError))

def test_ignore_broken_distributions_raises_exceptions_by_default(self):
# Make sure that the distributions from eggs are already in the working
# set. This includes acme.foo, with version 0.1a1.
for dist in pkg_resources.find_distributions(self.eggs_dir):
pkg_resources.working_set.add(dist)

plugin_manager = EggBasketPluginManager(
plugin_path=[
self.bad_eggs_dir,
Copy link
Member Author

Choose a reason for hiding this comment

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

I'm fairly sure that we don't need the bad_eggs_dir for this test.

# Attempt to add acme.foo, with conflicting version 0.1a11
self._create_broken_distribution_eggdir("acme.foo*.egg"),
],
)
with self.assertRaises(SystemError):
iter(plugin_manager)

def test_ignore_broken_distributions_loads_good_distributions(self):
# Make sure that the distributions from eggs are already in the working
# set. This includes acme.foo, with version 0.1a1.
for dist in pkg_resources.find_distributions(self.eggs_dir):
pkg_resources.working_set.add(dist)

data = {"count": 0}

def on_broken_distribution(dist, exc):
Expand Down