Browse Source

Added tests

master
cofob 10 months ago
parent
commit
bf940a06d8
No known key found for this signature in database GPG Key ID: BA5F250F390317D6
  1. 6
      funcs.py
  2. 15
      tests/test_funcs.py

6
funcs.py

@ -26,9 +26,13 @@ def import_module(module):
return import_module_from_spec(module_spec)
def get_path(args):
def get_path(*args):
if len(args) == 0:
raise AttributeError
if len(args) == 1:
if isinstance(args[0], str):
return args[0]
args = args[0]
if len(args) == 1:
return args[0]
path = args[0]

15
tests/test_funcs.py

@ -0,0 +1,15 @@
import pytest
import funcs
def check_getpath():
assert funcs.get_path('test', 'test1') == 'test/test1'
assert funcs.get_path(['test', 'test1']) == 'test/test1'
assert funcs.get_path(['test']) == 'test'
assert funcs.get_path('test') == 'test'
try:
funcs.get_path()
except AttributeError:
pass
except:
raise Exception('Returned invalid error')