Coding style.
- Update asyncio code to latest style using asyncio.run().
This commit is contained in:
parent
2bb586c862
commit
0679cb14b5
4 changed files with 46 additions and 65 deletions
|
|
@ -33,12 +33,6 @@ def _assert_widget_appearance(widget, golden_path, dimensions=_DIMENSIONS):
|
|||
golden.assertGolden(_widget_to_string(widget, dimensions), golden_path_absolute)
|
||||
|
||||
|
||||
class _MockMainLoop:
|
||||
|
||||
def add_reader(self, foo, bar):
|
||||
pass
|
||||
|
||||
|
||||
class ScreenWidgetTestCase(unittest.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
|
|
@ -50,7 +44,7 @@ class ScreenWidgetTestCase(unittest.TestCase):
|
|||
jobs_added_event = asyncio.Event()
|
||||
summary = __main__.Summary(project_dir, jobs_added_event)
|
||||
log = __main__.Log()
|
||||
self.main_widget = __main__.Screen(summary, log, _MockMainLoop())
|
||||
self.main_widget = __main__.Screen(summary, log)
|
||||
|
||||
def tearDown(self):
|
||||
shutil.rmtree(self.temp_dir)
|
||||
|
|
@ -111,6 +105,7 @@ class SummaryCursorTest(unittest.TestCase):
|
|||
class SummarySyncWithFilesystemTestCase(unittest.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
fill3.APPEARANCE_CHANGED_EVENT = asyncio.Event()
|
||||
self.temp_dir = tempfile.mkdtemp()
|
||||
self.foo_path = os.path.join(self.temp_dir, "foo")
|
||||
self.bar_path = os.path.join(self.temp_dir, "bar.md")
|
||||
|
|
@ -198,31 +193,31 @@ def _tmp_total():
|
|||
class MainTestCase(unittest.TestCase):
|
||||
|
||||
def test_main_and_restart_and_no_leaks_and_is_relocatable(self):
|
||||
def test_run(root_path, loop):
|
||||
def test_run(root_path):
|
||||
mount_total = _mount_total()
|
||||
tmp_total = _tmp_total()
|
||||
foo_path = os.path.join(root_path, "foo")
|
||||
open(foo_path, "w").close()
|
||||
__main__.manage_cache(root_path)
|
||||
with __main__.chdir(root_path):
|
||||
loop = asyncio.get_event_loop()
|
||||
with contextlib.redirect_stdout(io.StringIO()):
|
||||
__main__.main(root_path, loop, worker_count=2, is_being_tested=True)
|
||||
loop.run_until_complete(__main__.main(
|
||||
root_path, worker_count=2, is_being_tested=True))
|
||||
for file_name in ["summary.pickle", "creation_time",
|
||||
"foo-metadata", "foo-contents"]:
|
||||
self.assertTrue(os.path.exists(".eris/" + file_name))
|
||||
self.assertEqual(_mount_total(), mount_total)
|
||||
self.assertEqual(_tmp_total(), tmp_total)
|
||||
|
||||
temp_dir = tempfile.mkdtemp()
|
||||
try:
|
||||
loop = asyncio.get_event_loop()
|
||||
first_dir = os.path.join(temp_dir, "first")
|
||||
os.mkdir(first_dir)
|
||||
test_run(first_dir, loop)
|
||||
test_run(first_dir)
|
||||
second_dir = os.path.join(temp_dir, "second")
|
||||
os.rename(first_dir, second_dir)
|
||||
test_run(second_dir, loop)
|
||||
loop.close()
|
||||
loop.stop()
|
||||
test_run(second_dir)
|
||||
finally:
|
||||
shutil.rmtree(temp_dir)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue