diff options
author | Damien George <damien.p.george@gmail.com> | 2018-02-07 15:55:52 +1100 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2018-02-07 15:55:52 +1100 |
commit | 1f53ff61fffb4cc9b42ddf7e331e225c1b48b4ff (patch) | |
tree | 4a55678c160d57992327301a24df84f1b938734d /tests/basics/builtin_setattr.py | |
parent | b45c8c17f0f295e919a90659d4c1880a47b228c1 (diff) | |
download | micropython-1f53ff61fffb4cc9b42ddf7e331e225c1b48b4ff.tar.gz micropython-1f53ff61fffb4cc9b42ddf7e331e225c1b48b4ff.zip |
tests/basics: Rename remaining tests that are for built-in functions.
For consistency with all of the other tests that are named builtin_XXX.py.
Diffstat (limited to 'tests/basics/builtin_setattr.py')
-rw-r--r-- | tests/basics/builtin_setattr.py | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/tests/basics/builtin_setattr.py b/tests/basics/builtin_setattr.py new file mode 100644 index 0000000000..e4acb14cac --- /dev/null +++ b/tests/basics/builtin_setattr.py @@ -0,0 +1,25 @@ +class A: + + var = 132 + + def __init__(self): + self.var2 = 34 + + +a = A() +setattr(a, "var", 123) +setattr(a, "var2", 56) +print(a.var) +print(a.var2) + +try: + setattr(a, b'var3', 1) +except TypeError: + print('TypeError') + +# try setattr on a built-in function +try: + setattr(int, 'to_bytes', 1) +except (AttributeError, TypeError): + # uPy raises AttributeError, CPython raises TypeError + print('AttributeError/TypeError') |