Hey everyone,
Right know I am trying to mock some userinterface functions, so I can more easily test my plugins. However when I perform the test, the test succeeds and after that Rhino 7 crashes. Since the plugin is not build into IronPython, I am currently manually importing the package Mock (version 1.0.0. since it has no dependencies).
Does anyone have experience with this issue? Are you using a more compatible version of a mocking tool, if so which one? Or does Rhino not allow for the mocking of it is scriptsyntax tools?
With kind regards,
Hajo
The example of my code is as following:
"import sys
PATH = “~\Mock\mock-1.0.0\mock-1.0.0”
if PATH not in sys.path:
sys.path.append(PATH)
from mock import patch
from unittest import TestCase
import unittest
import rhinoscriptsyntax as rs
def get_input(text):
return input(test)
def answer():
ans = rs.GetString(“Give yes or no”)
if ans == “yes”:
return “You answered yes”
if ans == “no”:
return “You answered no”
class Test(TestCase):
@patch(‘rs.GetString’, return_value = “yes”)
def test_answer_yes(self, input):
self.asserEqual(answer(),“You answered yes”)
if name == ‘main’:
unittest.main()"