Fix `FileNotFoundError` if file is just the filename. #226

This commit is contained in:
Fabio Caccamo 2023-01-11 11:12:02 +01:00
parent cf1e9ac687
commit ff2527eca7
3 changed files with 24 additions and 2 deletions

View File

@ -4,7 +4,7 @@ mailchecker == 5.0.6
openpyxl == 3.0.10
phonenumbers == 8.13.4
python-dateutil == 2.8.2
python-fsutil == 0.9.1
python-fsutil == 0.9.2
python-slugify == 7.0.0
pyyaml == 6.0
requests == 2.28.1

View File

@ -102,7 +102,7 @@ install_requires =
openpyxl >= 3.0.0, < 4.0.0
phonenumbers >= 8.12.0, < 9.0.0
python-dateutil >= 2.8.0, < 3.0.0
python-fsutil >= 0.9.1, < 1.0.0
python-fsutil >= 0.9.2, < 1.0.0
python-slugify >= 6.0.1, < 8.0.0
pyyaml >= 6.0, < 7.0
requests >= 2.26.0, < 3.0.0

View File

@ -0,0 +1,22 @@
import unittest
import fsutil
from benedict import benedict
class github_issue_0226_test_case(unittest.TestCase):
"""
This class describes a github issue 0226 test case.
https://github.com/fabiocaccamo/python-benedict/issues/226
To run this specific test:
- Run python -m unittest tests.github.test_issue_0226
"""
def test_file_not_found_error_if_filepath_is_just_filename(self):
b = benedict({"a": 1, "b": 2, "c": 3, "x": 7, "y": 8, "z": 9})
filepath = "test.yml"
b.to_yaml(filepath=filepath)
self.assertTrue(fsutil.is_file(filepath))
fsutil.remove_file(filepath)