forked from grizz/pymdgen
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix python 3.12 compatability issue (#20)
* fix python 3.12 compatability issue * add pytest for getargspec --------- Co-authored-by: Matt Griswold <[email protected]>
- Loading branch information
Showing
2 changed files
with
55 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import inspect | ||
from functools import wraps | ||
from pymdgen import getargspec # Import your __init__.py module | ||
|
||
|
||
def test_getargspec_simple_function(): | ||
def my_function(a, b, c=10): | ||
pass | ||
expected_result = [ | ||
['a', 'b', 'c'], | ||
None, | ||
None, | ||
[10,], | ||
] | ||
assert getargspec(my_function) == expected_result | ||
|
||
def test_getargspec_args_kwargs(): | ||
def my_function(a, b, *args, **kwargs): | ||
pass | ||
expected_result = [ | ||
['a', 'b', 'args', 'kwargs'], | ||
None, | ||
None, | ||
[], | ||
] | ||
assert getargspec(my_function) == expected_result | ||
|
||
def test_getargspec_decorated_function(): | ||
def my_decorator(func): | ||
@wraps(func) | ||
def wrapper(*args, **kwargs): | ||
return func(*args, **kwargs) | ||
return wrapper | ||
|
||
@my_decorator | ||
def my_function(a, b, c=20): | ||
pass | ||
|
||
expected_result = [ | ||
['a', 'b', 'c'], | ||
None, | ||
None, | ||
[20,], | ||
] | ||
assert getargspec(my_function) == expected_result |