-
-
Notifications
You must be signed in to change notification settings - Fork 271
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make the tests compatible with pytest (#323)
* make multi model row count use pytest rather than unittest * fix arg count test * run1psub0 * add param sweep * add test runs not zero * add policy aggregation * add import nb * add timestep1psub0 * add empty cadCAD exp test --------- Co-authored-by: Emanuel Lima <[email protected]>
- Loading branch information
1 parent
5241edf
commit ec70d5d
Showing
18 changed files
with
289 additions
and
243 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import pandas as pd | ||
from tabulate import tabulate | ||
from testing.results_comparison import dataframe_difference, compare_results_pytest | ||
from cadCAD import configs | ||
from cadCAD.engine import ExecutionMode, ExecutionContext, Executor | ||
import pytest | ||
|
||
|
||
@pytest.fixture | ||
def empty_experiment(): | ||
exec_mode = ExecutionMode() | ||
exec_ctx = ExecutionContext(context=exec_mode.local_mode) | ||
run = Executor(exec_context=exec_ctx, configs=configs) | ||
raw_result, _, _ = run.execute() | ||
|
||
result_df = pd.DataFrame(raw_result) | ||
expected_df = pd.read_pickle("expected_results/param_sweep_4.pkl") | ||
return dataframe_difference(result_df, expected_df) | ||
|
||
|
||
def test_experiment(empty_experiment): | ||
compare_results_pytest(empty_experiment) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import os, subprocess, json | ||
from testing.utils import assertEqual | ||
|
||
def test_jupyter_nbconvert_row_count(): | ||
command = f'jupyter nbconvert --to=notebook --ExecutePreprocessor.enabled=True {os.getcwd()}/testing/tests/import_cadCAD.ipynb' | ||
process = subprocess.Popen(command.split(), stdout=subprocess.PIPE) | ||
process.communicate() | ||
json_path = f'{os.getcwd()}/testing/tests/cadCAD_memory_address.json' | ||
memory_address = json.load(open(json_path))['memory_address'] | ||
assertEqual(type(memory_address) == str, True, "cadCAD is not importable by jupyter server") |
Oops, something went wrong.