Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Norberg committed Nov 2, 2020
1 parent 075cef3 commit bed4c37
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 9 deletions.
6 changes: 4 additions & 2 deletions tests/test_color_palettes_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import importlib
import os
from tempfile import TemporaryDirectory

Expand Down Expand Up @@ -44,9 +45,10 @@ def test_color_palettes_config(monkeypatch):
# XXX (dano): CHARTIFY_CONFIG_DIR must end with /
monkeypatch.setenv('CHARTIFY_CONFIG_DIR', os.path.join(tmp, ''))

# (re-)import options module to reload configuration
# reload modules to reload configuration
import chartify._core.options
import chartify._core.colors
import importlib
importlib.reload(chartify._core.options)
importlib.reload(chartify._core.colors)

# Check that the expected palettes are loaded
Expand Down
4 changes: 4 additions & 0 deletions tests/test_colors.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import chartify
import importlib
import numpy as np


Expand All @@ -25,6 +26,9 @@ def test_color(self):

class TestColorPalettes:
def test_getitem(self):
# reload configuration
importlib.reload(chartify)

palette = chartify.color_palettes['Category20']
assert (isinstance(palette, chartify._core.colors.ColorPalette))
assert (palette.name == 'Category20')
Expand Down
8 changes: 6 additions & 2 deletions tests/test_colors_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import importlib
import os
from tempfile import TemporaryDirectory

Expand Down Expand Up @@ -52,10 +53,13 @@ def test_colors_config(monkeypatch):
# XXX (dano): CHARTIFY_CONFIG_DIR must end with /
monkeypatch.setenv('CHARTIFY_CONFIG_DIR', os.path.join(tmp, ''))

# (re-)import options module to reload configuration
# reload modules to reload configuration
import chartify._core.options
import chartify._core.colors
import importlib
import chartify._core.style
importlib.reload(chartify._core.options)
importlib.reload(chartify._core.colors)

import chartify._core.colour as colour
assert colour.COLOR_NAME_TO_RGB['foo'] == (0, 100, 80)
assert colour.COLOR_NAME_TO_RGB['bar'] == (25, 20, 20)
Expand Down
4 changes: 4 additions & 0 deletions tests/test_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,13 @@
"""Tests for `chartify` package."""

import chartify
import importlib


def test_examples():
# reload configuration
importlib.reload(chartify)

excluded_examples = ['chart_show']
public_examples = [
attr for attr in dir(chartify.examples) if
Expand Down
8 changes: 4 additions & 4 deletions tests/test_options_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import importlib
import os
from tempfile import TemporaryDirectory

Expand Down Expand Up @@ -53,11 +54,10 @@ def test_options_config(monkeypatch):
# XXX (dano): CHARTIFY_CONFIG_DIR must end with /
monkeypatch.setenv('CHARTIFY_CONFIG_DIR', os.path.join(tmp, ''))

# (re-)import options module to reload configuration
# reload modules to reload configuration
import chartify._core.options
import importlib
chartify = importlib.reload(chartify._core.options)
options = importlib.reload(chartify._core.options)

config = {key: chartify.options.get_option(key)
config = {key: options.options.get_option(key)
for key in EXPECTED_CONFIG}
assert config == EXPECTED_CONFIG
8 changes: 7 additions & 1 deletion tests/test_style_settings_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import importlib
import os
from tempfile import TemporaryDirectory

Expand All @@ -34,8 +35,13 @@ def test_style_settings_config(monkeypatch):
# XXX (dano): CHARTIFY_CONFIG_DIR must end with /
monkeypatch.setenv('CHARTIFY_CONFIG_DIR', os.path.join(tmp, ''))

# Check that the expected style is loaded
# reload modules to reload configuration
import chartify._core.options
import chartify._core.style
importlib.reload(chartify._core.options)
importlib.reload(chartify._core.style)

# Check that the expected style is loaded
style = chartify._core.style.Style(None, '')

import yaml
Expand Down

0 comments on commit bed4c37

Please sign in to comment.