-
Notifications
You must be signed in to change notification settings - Fork 3
VZ print error message #79
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
e851cd2
6230104
8511937
7d78d05
1a1f0e9
d2fcd3c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -12,8 +12,7 @@ | |||||||||||||
| session_path = None | ||||||||||||||
| test_lib_path = os.path.join(temp_path.name, "stsimLibrary.ssim") | ||||||||||||||
| lib_name = "spatial-example.ssim" | ||||||||||||||
| git_repo_path = "C:/Users/VickiZhang/Documents/GH_ApexRMS" | ||||||||||||||
| # git_repo_path = "C:/gitprojects" | ||||||||||||||
| git_repo_path = "C:/GH_ApexRMS" | ||||||||||||||
| lib_path = os.path.join(git_repo_path, "pysyncrosim/tests", lib_name) | ||||||||||||||
| lib_backup_path = os.path.join(git_repo_path, "pysyncrosim/tests", "spatial-example.ssimbak") | ||||||||||||||
|
Comment on lines
+15
to
17
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hardcoded absolute path reduces test portability. The path 🛠️ Suggested fix using environment variable-git_repo_path = "C:/GH_ApexRMS"
+git_repo_path = os.environ.get("PYSYNCROSIM_TEST_REPO_PATH", "C:/GH_ApexRMS")Alternatively, use a path relative to the test file: -git_repo_path = "C:/GH_ApexRMS"
+git_repo_path = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||
|
|
||||||||||||||
|
|
@@ -932,6 +931,22 @@ def test_scenario_run_and_results(): | |||||||||||||
| assert not isinstance(myScenario.run_log(), pd.DataFrame) | ||||||||||||||
|
|
||||||||||||||
| myLibrary.delete(force=True) | ||||||||||||||
|
|
||||||||||||||
| def test_scenario_run_failure(): | ||||||||||||||
|
|
||||||||||||||
| mySession = ps.Session(session_path) | ||||||||||||||
| mySession.restore(lib_backup_path) | ||||||||||||||
|
|
||||||||||||||
| myLibrary = ps.library(name=lib_path, | ||||||||||||||
| session=mySession, | ||||||||||||||
| force_update=True) | ||||||||||||||
|
|
||||||||||||||
| myScenario = myLibrary.scenarios(name="My Scenario") | ||||||||||||||
| myFailScenario = myScenario.copy(name="My Scenario - Failure Test") | ||||||||||||||
| myFailScenario.delete(force=True) | ||||||||||||||
|
|
||||||||||||||
| with pytest.raises(RuntimeError, match="Run failed for Scenario"): | ||||||||||||||
| myFailScenario.run() | ||||||||||||||
|
|
||||||||||||||
| def test_scenario_copy_dep_delete(): | ||||||||||||||
|
|
||||||||||||||
|
|
@@ -1026,8 +1041,8 @@ def test_scenario_copy_dep_delete(): | |||||||||||||
|
|
||||||||||||||
| # Test delete | ||||||||||||||
| myNewScn.delete(force=True) | ||||||||||||||
| emptyResScn = myNewScn.run() | ||||||||||||||
| assert emptyResScn is None | ||||||||||||||
| with pytest.raises(RuntimeError, match = "Run failed for Scenario"): | ||||||||||||||
| myNewScn.run() | ||||||||||||||
|
|
||||||||||||||
| # Delete other scenarios | ||||||||||||||
| sameNameScn.delete(force=True) | ||||||||||||||
|
|
||||||||||||||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function may return
Noneimplicitly when results are empty and no error occurred.When
results_df.emptyisTrueanderror_msgisNone, the function exits without an explicit return, implicitly returningNone. This doesn't match the docstring which states it returns aScenario. Consider whether this edge case should print a warning or return something more explicit.🤖 Prompt for AI Agents
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this edge case where no results scenario is created after a run failure should never happen
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@vickimzhang, thanks for the clarification! If SyncroSim always produces a result scenario on a successful run, then that implicitNonepath is indeed unreachable and the current logic is correct. I'll note this for future reviews.✏️ Learnings added