Skip to content

Commit

Permalink
Python support: test for an unknown local and remote file (#2178).
Browse files Browse the repository at this point in the history
  • Loading branch information
agarny committed Dec 9, 2019
1 parent e79887a commit f882ec7
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 3 deletions.
12 changes: 12 additions & 0 deletions src/plugins/support/PythonSupport/tests/data/tests.out
@@ -1,3 +1,15 @@
---------------------------------------
Unknown local file
---------------------------------------
- Open file...
OSError("'src/plugins/support/PythonSupport/tests/data/../../../../../../models/tests/unknown' could not be opened.")

---------------------------------------
Unknown remote file
---------------------------------------
- Open file...
OSError("'https://unknown' could not be opened (host unknown not found).")

---------------------------------------
Local CellML file
---------------------------------------
Expand Down
13 changes: 12 additions & 1 deletion src/plugins/support/PythonSupport/tests/data/tests.py
Expand Up @@ -40,7 +40,18 @@ def run_simulation(title, file_name_or_url, first=True):
oc.close_simulation(simulation)


run_simulation('Local CellML file', 'cellml/lorenz.cellml')
try:
run_simulation('Unknown local file', 'unknown')
except Exception as e:
print(repr(e))

try:
run_simulation('Unknown remote file',
'https://unknown', False)
except Exception as e:
print(repr(e))

run_simulation('Local CellML file', 'cellml/lorenz.cellml', False)
run_simulation('Remote CellML file',
'https://raw.githubusercontent.com/opencor/opencor/master/models/tests/cellml/lorenz.cellml', False)

Expand Down
2 changes: 1 addition & 1 deletion src/tests/src/testsutils.cpp
Expand Up @@ -162,7 +162,7 @@ int runCli(const QStringList &pArguments, QStringList &pOutput)
QDir::setCurrent(origPath);
#endif

pOutput = output.remove('\r').split('\n');
pOutput = output.remove(dirName()).remove('\r').split('\n');

return process.exitCode();
}
Expand Down
2 changes: 1 addition & 1 deletion src/tests/src/testsutils.h
Expand Up @@ -33,7 +33,7 @@ namespace OpenCOR {

//==============================================================================

QString dirName(const QString &pDirName);
QString dirName(const QString &pDirName = QString());
QString fileName(const QString &pFileName);

QByteArray rawFileContents(const QString &pFileName);
Expand Down

0 comments on commit f882ec7

Please sign in to comment.