def test_invalid_value(self):
     with pytest.raises(TypeError, match="Could not convert value"):
         IS(0.9)
     with pytest.raises(TypeError, match="Could not convert value"):
         IS("0.9")
     with pytest.raises(ValueError, match="could not convert string"):
         IS("foo")
Exemple #2
0
def load_dvh_json(file_path_name):
    """

    :param file_path_name:
    :return:
    """

    with open(file_path_name, 'r', encoding='utf-8') as json_file:
        json_dict = json.load(json_file)
        # add pydicom key type (int)
        json_dict = {IS(k): v for k, v in json_dict.items()}
        return json_dict
 def test_valid_value(self):
     assert 42 == IS(42)
     assert 42 == IS("42")
     assert 42 == IS("42.0")
     assert 42 == IS(42.0)
 def test_empty_value(self):
     assert IS(None) is None
     assert IS("") is None
 def test_invalid_value(self):
     with pytest.raises(TypeError, match='Could not convert value'):
         IS(0.9)
     with pytest.raises(ValueError, match='invalid literal for int()'):
         IS('0.9')
 def test_valid_value(self):
     assert 42 == IS(42)
     assert 42 == IS('42')
     assert 42 == IS(42.0)
 def test_empty_value(self):
     assert '' == IS(None)
     assert '' == IS('')
 def test_invalid_value(self):
     with pytest.raises(TypeError, match="Could not convert value"):
         IS(0.9)
     with pytest.raises(ValueError, match="invalid literal for int()"):
         IS("0.9")