def test_builds_before_running_tests(self): self.addCleanup(set_command, 'packaging.command.build.build') set_command('packaging.tests.test_command_test.MockBuildCmd') dist = Distribution() dist.get_command_obj('build')._record = record = [] cmd = test(dist) cmd.runner = self.prepare_named_function(lambda: None) cmd.ensure_finalized() cmd.run() self.assertEqual(['build has run'], record)