From 997dbf9908eafba2321e4aa439f79d0157864c83 Mon Sep 17 00:00:00 2001 From: Felix Schwarz Date: Wed, 14 Aug 2024 09:37:51 +0200 Subject: [PATCH] remove dependency on "FakeFSHelpers" --- setup.cfg | 1 - tests/includes_with_umlauts_test.py | 28 +++++++++++++++++----------- 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/setup.cfg b/setup.cfg index c658e69..b3070ca 100644 --- a/setup.cfg +++ b/setup.cfg @@ -55,7 +55,6 @@ exclude = [options.extras_require] testing = - FakeFSHelpers HTMLCompare >= 0.3.0 # >= 0.3.0: ability to ignore attribute ordering in HTML lxml pytest diff --git a/tests/includes_with_umlauts_test.py b/tests/includes_with_umlauts_test.py index e97bd29..4edc97d 100644 --- a/tests/includes_with_umlauts_test.py +++ b/tests/includes_with_umlauts_test.py @@ -1,20 +1,24 @@ +import os +from contextlib import contextmanager from io import StringIO -import pytest -from schwarz.fakefs_helpers import FakeFS - from mjml import mjml_to_html -@pytest.fixture -def fs(): - _fs = FakeFS.set_up() - yield _fs - _fs.tear_down() +# could use "contextlib.chdir" in Python 3.11+ +# https://github.com/python/cpython/commit/3592980f9122ab0d9ed93711347742d110b749c2 +@contextmanager +def chdir(path): + old_chdir = os.getcwd() + try: + os.chdir(path) + yield + finally: + os.chdir(old_chdir) -def test_can_properly_handle_include_umlauts(fs): +def test_can_properly_handle_include_umlauts(tmp_path): included_mjml = ( '' ' ' @@ -30,9 +34,11 @@ def test_can_properly_handle_include_umlauts(fs): ' ' '' ) - fs.create_file('footer.mjml', contents=included_mjml.encode('utf8')) + path_footer = tmp_path / 'footer.mjml' + path_footer.write_text(included_mjml, encoding='utf8') - result = mjml_to_html(StringIO(mjml)) + with chdir(tmp_path): + result = mjml_to_html(StringIO(mjml)) html = result.html assert ('äöüß' in html)