2019-09-10 00:54:28 +00:00
|
|
|
# Created By: Virgil Dupras
|
|
|
|
# Created On: 2006/02/21
|
|
|
|
# Copyright 2015 Hardcoded Software (http://www.hardcoded.net)
|
|
|
|
|
2020-01-01 02:16:27 +00:00
|
|
|
# This software is licensed under the "GPLv3" License as described in the "LICENSE" file,
|
|
|
|
# which should be included with this package. The terms are also available at
|
2019-09-10 00:54:28 +00:00
|
|
|
# http://www.gnu.org/licenses/gpl-3.0.html
|
|
|
|
|
2022-03-28 04:50:03 +00:00
|
|
|
from ..path import pathify
|
|
|
|
from pathlib import Path
|
2020-01-01 02:16:27 +00:00
|
|
|
|
2019-09-10 00:54:28 +00:00
|
|
|
|
|
|
|
def test_pathify():
|
|
|
|
@pathify
|
2020-01-01 02:16:27 +00:00
|
|
|
def foo(a: Path, b, c: Path):
|
2019-09-10 00:54:28 +00:00
|
|
|
return a, b, c
|
2020-01-01 02:16:27 +00:00
|
|
|
|
|
|
|
a, b, c = foo("foo", 0, c=Path("bar"))
|
2019-09-10 00:54:28 +00:00
|
|
|
assert isinstance(a, Path)
|
2020-01-01 02:16:27 +00:00
|
|
|
assert a == Path("foo")
|
2019-09-10 00:54:28 +00:00
|
|
|
assert b == 0
|
|
|
|
assert isinstance(c, Path)
|
2020-01-01 02:16:27 +00:00
|
|
|
assert c == Path("bar")
|
|
|
|
|
2019-09-10 00:54:28 +00:00
|
|
|
|
|
|
|
def test_pathify_preserve_none():
|
|
|
|
# @pathify preserves None value and doesn't try to return a Path
|
|
|
|
@pathify
|
|
|
|
def foo(a: Path):
|
|
|
|
return a
|
2020-01-01 02:16:27 +00:00
|
|
|
|
2019-09-10 00:54:28 +00:00
|
|
|
a = foo(None)
|
|
|
|
assert a is None
|