def test_create_numpy_tile(): p = prefab.Prefab((255, 0, 0)) p.size = 2 tile_numpy_out = np.array([[[1, 0, 0], [1, 0, 0]], [[1, 0, 0], [1, 0.0, 0]]]) assert np.array_equal(p.numpy_tile, tile_numpy_out)
def test_size_prefab_success(): p = prefab.Prefab((255, 255, 255)) p.size = 100 assert p.size == 100
def test_size_prefab_val(size_input, expect_msg): with pytest.raises(ValueError) as execinfo: p = prefab.Prefab((255, 255, 255)) p.size = size_input assert expect_msg in str(execinfo.value)
def test_prefab_color_setter_success(): p = prefab.Prefab((255, 255, 255)) p.color = (200, 200, 200) assert p.color == (200, 200, 200)
def test_prefab_color_setter(color_input, expect_msg): with pytest.raises(TypeError) as execinfo: p = prefab.Prefab((255, 255, 255)) p.color = color_input assert expect_msg in str(execinfo.value)
def test_prefab_color_wrong_type_tuple(color_input, expect_msg): with pytest.raises(ValueError) as execinfo: p = prefab.Prefab(color_input) assert expect_msg in str(execinfo.value)
def normal_prefab(): return prefab.Prefab((255, 0, 0))