| 42 | }; |
| 43 | |
| 44 | TEST_F(PythonEngineFixture, BadMeasure) { |
| 45 | |
| 46 | const std::string classAndDirName = "BadMeasure"; |
| 47 | |
| 48 | const auto scriptPath = getScriptPath(classAndDirName); |
| 49 | auto measureScriptObject = (*thisEngine)->loadMeasure(scriptPath, classAndDirName); |
| 50 | auto* measurePtr = (*thisEngine)->getAs<openstudio::measure::ModelMeasure*>(measureScriptObject); |
| 51 | |
| 52 | ASSERT_EQ(measurePtr->name(), "Bad Measure"); |
| 53 | |
| 54 | std::string expected_exception = fmt::format(R"(SWIG director method error. In method 'arguments': `ValueError('oops')` |
| 55 | |
| 56 | Traceback (most recent call last): |
| 57 | File "{0}", line 22, in arguments |
| 58 | self.another_method() |
| 59 | File "{0}", line 19, in another_method |
| 60 | raise ValueError("oops") |
| 61 | ValueError: oops)", |
| 62 | scriptPath.generic_string()); |
| 63 | |
| 64 | openstudio::model::Model model; |
| 65 | try { |
| 66 | measurePtr->arguments(model); |
| 67 | ASSERT_FALSE(true) << "Expected measure arguments(model) to throw"; |
| 68 | } catch (std::exception& e) { |
| 69 | std::string error = e.what(); |
| 70 | EXPECT_EQ(expected_exception, error); |
| 71 | } |
| 72 | } |
| 73 | |
| 74 | TEST_F(PythonEngineFixture, WrongMethodMeasure) { |
| 75 | |