Commit 7f3027b6 authored by Michael Droettboom's avatar Michael Droettboom

Fix tests

parent 9836791b
...@@ -45,24 +45,27 @@ var languagePluginLoader = new Promise((resolve, reject) => { ...@@ -45,24 +45,27 @@ var languagePluginLoader = new Promise((resolve, reject) => {
const package = _uri_to_package_name(package_uri); const package = _uri_to_package_name(package_uri);
if (package == null) { if (package == null) {
throw new Error(`Invalid package name or URI '${package_uri}'`); console.error(`Invalid package name or URI '${package_uri}'`);
return;
} else if (package == package_uri) { } else if (package == package_uri) {
package_uri = 'default channel'; package_uri = 'default channel';
} }
if (package in loadedPackages) { if (package in loadedPackages) {
if (package_uri != loadedPackages[package]) { if (package_uri != loadedPackages[package]) {
throw new Error( console.error(
`URI mismatch, attempting to load package ` + `URI mismatch, attempting to load package ` +
`${package} from ${package_uri} while it is already ` + `${package} from ${package_uri} while it is already ` +
`loaded from ${loadedPackages[package]}!`); `loaded from ${loadedPackages[package]}!`);
return;
} }
} else if (package in toLoad) { } else if (package in toLoad) {
if (package_uri != toLoad[package]) { if (package_uri != toLoad[package]) {
throw new Error( console.error(
`URI mismatch, attempting to load package ` + `URI mismatch, attempting to load package ` +
`${package} from ${package_uri} while it is already ` + `${package} from ${package_uri} while it is already ` +
`being loaded from ${toLoad[package]}!`); `being loaded from ${toLoad[package]}!`);
return;
} }
} else { } else {
console.log(`Loading ${package} from ${package_uri}`); console.log(`Loading ${package} from ${package_uri}`);
...@@ -125,8 +128,7 @@ var languagePluginLoader = new Promise((resolve, reject) => { ...@@ -125,8 +128,7 @@ var languagePluginLoader = new Promise((resolve, reject) => {
let loadPackage = (names) => { let loadPackage = (names) => {
/* We want to make sure that only one loadPackage invocation runs at any /* We want to make sure that only one loadPackage invocation runs at any
* given time, so this creates a "chain" of promises. */ * given time, so this creates a "chain" of promises. */
loadPackagePromise = loadPackagePromise.then(() => _loadPackage(names)) loadPackagePromise = loadPackagePromise.then(() => _loadPackage(names));
.catch((e) => console.log(e.to_string()));
return loadPackagePromise; return loadPackagePromise;
}; };
......
...@@ -13,6 +13,9 @@ ...@@ -13,6 +13,9 @@
console.info = function(message) { console.info = function(message) {
window.logs.push(message); window.logs.push(message);
} }
console.error = function(message) {
window.logs.push(message);
}
</script> </script>
<script src="pyodide_dev.js"></script> <script src="pyodide_dev.js"></script>
</head> </head>
......
...@@ -25,14 +25,12 @@ def test_uri_mismatch(selenium_standalone): ...@@ -25,14 +25,12 @@ def test_uri_mismatch(selenium_standalone):
def test_invalid_package_name(selenium): def test_invalid_package_name(selenium):
with pytest.raises(WebDriverException, selenium.load_package('wrong name+$')
match="Invalid package name or URI"): assert "Invalid package name or URI" in selenium.logs
selenium.load_package('wrong name+$')
selenium.clean_logs() selenium.clean_logs()
with pytest.raises(WebDriverException, selenium.load_package('tcp://some_url')
match="Invalid package name or URI"): assert "Invalid package name or URI" in selenium.logs
selenium.load_package('tcp://some_url')
@pytest.mark.parametrize('packages', [['pyparsing', 'pytz'], @pytest.mark.parametrize('packages', [['pyparsing', 'pytz'],
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment