From e0569815b536018369a39a7b3655546b4f897dc0 Mon Sep 17 00:00:00 2001 From: rdb Date: Wed, 21 Feb 2018 15:56:45 +0100 Subject: [PATCH] tests: add test for prc page and one for light color temperature --- tests/pgraph/test_light.py | 20 ++++++++++++++++++++ tests/prc/test_config_page.py | 12 ++++++++++++ 2 files changed, 32 insertions(+) create mode 100644 tests/pgraph/test_light.py create mode 100644 tests/prc/test_config_page.py diff --git a/tests/pgraph/test_light.py b/tests/pgraph/test_light.py new file mode 100644 index 0000000000..f303080b33 --- /dev/null +++ b/tests/pgraph/test_light.py @@ -0,0 +1,20 @@ +from panda3d import core + +def luminance(col): + return 0.2126 * col[0] + 0.7152 * col[1] + 0.0722 * col[2] + + +def test_light_colortemp(): + # Default is all white, assuming a D65 white point. + light = core.PointLight("light") + assert light.color == (1, 1, 1, 1) + assert light.color_temperature == 6500 + + # When setting color temp, it should preserve luminance. + for temp in range(2000, 15000): + light.color_temperature = temp + assert abs(luminance(light.color) - 1.0) < 0.001 + + # Setting it to the white point will make a white color. + light.color_temperature = 6500 + assert light.color.almost_equal((1, 1, 1, 1), 0.001) diff --git a/tests/prc/test_config_page.py b/tests/prc/test_config_page.py new file mode 100644 index 0000000000..5ca6cdb6ef --- /dev/null +++ b/tests/prc/test_config_page.py @@ -0,0 +1,12 @@ +from panda3d import core + +def test_load_unload_page(): + var = core.ConfigVariableInt("test-var", 1) + assert var.value == 1 + + page = core.load_prc_file_data("test_load_unload_page", "test-var 2") + assert page + assert var.value == 2 + + assert core.unload_prc_file(page) + assert var.value == 1