From 800579a430b619d98342e380c309228f1b0d2577 Mon Sep 17 00:00:00 2001 From: Dominik Holland Date: Thu, 1 Aug 2024 16:47:00 +0200 Subject: [PATCH] Fix utils to work with pathlib Also added an autotest for it --- qface/utils.py | 2 +- tests/test_generator.py | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/qface/utils.py b/qface/utils.py index d784bff..16520b8 100644 --- a/qface/utils.py +++ b/qface/utils.py @@ -19,6 +19,6 @@ def load_filters(path): ctx = { 'filters': {} } - exec(path.text(), ctx) + exec(path.read_text(), ctx) return ctx['filters'] diff --git a/tests/test_generator.py b/tests/test_generator.py index 9e1d53c..8a496b3 100644 --- a/tests/test_generator.py +++ b/tests/test_generator.py @@ -1,4 +1,5 @@ from qface.generator import FileSystem, Generator +from qface.utils import load_filters from unittest.mock import patch from io import StringIO import logging @@ -43,6 +44,10 @@ def test_parse_document(): system = FileSystem.parse(inputPath / 'com.pelagicore.ivi.tuner.qface') assert system.lookup('com.pelagicore.ivi.tuner') +def test_extra_filters(): + system = FileSystem.parse(inputPath / 'com.pelagicore.ivi.tuner.qface') + load_filters(Path('tests/templates/filters.py')) + assert system.lookup('com.pelagicore.ivi.tuner') def test_parse_document_list(): src = [inputPath / 'com.pelagicore.ivi.tuner.qface',