Skip to content

Commit

Permalink
tests for dottedfilename corner cases
Browse files Browse the repository at this point in the history
  • Loading branch information
amol- committed Mar 25, 2024
1 parent 76ef4a7 commit 69f57f8
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions tests/test_util.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# -*- coding: utf-8 -*-
import os
from datetime import datetime, timedelta
from unittest import mock

import pytest

Expand Down Expand Up @@ -144,6 +145,21 @@ def test_load_from_zipped_egg(self):
template = t.read()
assert template == '<p>Your application is now running</p>', template

def test_py38_support(self):
importlib_resources = mock.MagicMock(spec=["path"])
importlib_resources.path = mock.MagicMock(
return_value=mock.MagicMock(__enter__=mock.MagicMock(return_value="THISFILE"))
)
with mock.patch("importlib.resources", new=importlib_resources):
res = DottedFileNameFinder().get_dotted_filename('tg.tests_tests_py38_support')
assert res == os.path.abspath('THISFILE')

def test_filenotfound(self):
exc = FileNotFoundError()
exc.filename = "FILENAME"
with mock.patch("importlib.resources.as_file", side_effect=exc):
res = DottedFileNameFinder().get_dotted_filename('tg.tests_test_filenotfound')
assert res == os.path.abspath("FILENAME")

class TestLazyString(object):
def test_lazy_string_to_str(self):
Expand Down

0 comments on commit 69f57f8

Please sign in to comment.