From ed3e0c54993370553de226e03fc69a9cac30cc2a Mon Sep 17 00:00:00 2001 From: Roman Yurchak Date: Tue, 4 Sep 2018 16:48:02 +0200 Subject: [PATCH] TST Load multiple dependent and independent packages Also remove the (failing) tests with simultaneous package loading --- test/test_package_loading.py | 37 ++++++++++++------------------------ 1 file changed, 12 insertions(+), 25 deletions(-) diff --git a/test/test_package_loading.py b/test/test_package_loading.py index 05cd73c1e..6c9f725c1 100644 --- a/test/test_package_loading.py +++ b/test/test_package_loading.py @@ -1,6 +1,5 @@ import pytest from selenium.common.exceptions import WebDriverException -from .conftest import PackageLoaded def test_load_from_url(selenium_standalone, web_server): @@ -37,28 +36,16 @@ def test_invalid_package_name(selenium): selenium.load_package('tcp://some_url') -def test_load_packages_multiple(selenium_standalone): +@pytest.mark.parametrize('packages', [['pyparsing', 'pytz'], + ['pyparsing', 'matplotlib']], + ids='-'.join) +def test_load_packages_multiple(selenium_standalone, packages): selenium = selenium_standalone - selenium.load_package(['pyparsing', 'matplotlib']) - selenium.run('import pyparsing') - selenium.run('import matplotlib') - assert selenium.logs.count('Loading pyparsing') == 1 - - -@pytest.mark.xfail(reason='Not implemented') -def test_load_packages_simultaneous(selenium_standalone): - selenium = selenium_standalone - - from selenium.common.exceptions import TimeoutException - - selenium.run_js( - 'window.done = false\n' - 'pyodide.loadPackage("numpy")\n' - 'pyodide.loadPackage("matplotlib")' - '.then(function() { window.done = true; })') - try: - selenium.wait.until(PackageLoaded()) - except TimeoutException as exc: - print(selenium.logs) - raise TimeoutException() - assert selenium.logs.count('Loading numpy') == 1 + selenium.load_package(packages) + selenium.run(f'import {packages[0]}') + selenium.run(f'import {packages[1]}') + # The long must show that each package is loaded exactly once, + # including when one package is a dependency of the other + # ('pyparsing' and 'matplotlib') + assert selenium.logs.count(f'Loading {packages[0]}') == 1 + assert selenium.logs.count(f'Loading {packages[1]}') == 1