diff options
author | stijn <stijn@ignitron.net> | 2020-06-18 11:19:14 +0200 |
---|---|---|
committer | Damien George <damien@micropython.org> | 2020-09-04 00:10:24 +1000 |
commit | 40ad8f1666b265dafc7844d765f45cfae4b6299f (patch) | |
tree | d073a4b4f791f53d1a73c47d029bf2b49f041d5e /tests/basics | |
parent | b0932fcf2e2f9a81abf7737ed4b2573bd9ad4a49 (diff) | |
download | micropython-40ad8f1666b265dafc7844d765f45cfae4b6299f.tar.gz micropython-40ad8f1666b265dafc7844d765f45cfae4b6299f.zip |
all: Rename "sys" module to "usys".
This is consistent with the other 'micro' modules and allows implementing
additional features in Python via e.g. micropython-lib's sys.
Note this is a breaking change (not backwards compatible) for ports which
do not enable weak links, as "import sys" must now be replaced with
"import usys".
Diffstat (limited to 'tests/basics')
-rw-r--r-- | tests/basics/async_await2.py | 5 | ||||
-rw-r--r-- | tests/basics/async_for2.py | 5 | ||||
-rw-r--r-- | tests/basics/async_with2.py | 5 | ||||
-rw-r--r-- | tests/basics/attrtuple1.py | 5 | ||||
-rw-r--r-- | tests/basics/builtin_callable.py | 5 | ||||
-rw-r--r-- | tests/basics/builtin_dir.py | 5 | ||||
-rw-r--r-- | tests/basics/int_big1.py | 5 | ||||
-rw-r--r-- | tests/basics/module2.py | 4 | ||||
-rw-r--r-- | tests/basics/python34.py | 6 | ||||
-rw-r--r-- | tests/basics/string_compare.py | 5 | ||||
-rw-r--r-- | tests/basics/sys1.py | 5 | ||||
-rw-r--r-- | tests/basics/sys_exit.py | 5 | ||||
-rw-r--r-- | tests/basics/sys_getsizeof.py | 5 |
13 files changed, 49 insertions, 16 deletions
diff --git a/tests/basics/async_await2.py b/tests/basics/async_await2.py index 1e3164df93..56f77604ac 100644 --- a/tests/basics/async_await2.py +++ b/tests/basics/async_await2.py @@ -1,6 +1,9 @@ # test await expression -import sys +try: + import usys as sys +except ImportError: + import sys if sys.implementation.name == 'micropython': # uPy allows normal generators to be awaitables coroutine = lambda f: f diff --git a/tests/basics/async_for2.py b/tests/basics/async_for2.py index aad23a3e5a..4af3be4c6d 100644 --- a/tests/basics/async_for2.py +++ b/tests/basics/async_for2.py @@ -1,6 +1,9 @@ # test waiting within "async for" __anext__ function -import sys +try: + import usys as sys +except ImportError: + import sys if sys.implementation.name == 'micropython': # uPy allows normal generators to be awaitables coroutine = lambda f: f diff --git a/tests/basics/async_with2.py b/tests/basics/async_with2.py index 44421ae917..4dd1386240 100644 --- a/tests/basics/async_with2.py +++ b/tests/basics/async_with2.py @@ -1,6 +1,9 @@ # test waiting within async with enter/exit functions -import sys +try: + import usys as sys +except ImportError: + import sys if sys.implementation.name == 'micropython': # uPy allows normal generators to be awaitables coroutine = lambda f: f diff --git a/tests/basics/attrtuple1.py b/tests/basics/attrtuple1.py index 78a0fbed1b..249c030bb4 100644 --- a/tests/basics/attrtuple1.py +++ b/tests/basics/attrtuple1.py @@ -1,7 +1,10 @@ # test attrtuple # we can't test this type directly so we use sys.implementation object -import sys +try: + import usys as sys +except ImportError: + import sys t = sys.implementation # It can be just a normal tuple on small ports diff --git a/tests/basics/builtin_callable.py b/tests/basics/builtin_callable.py index 3ae49f004d..c0a9d0c473 100644 --- a/tests/basics/builtin_callable.py +++ b/tests/basics/builtin_callable.py @@ -7,7 +7,10 @@ print(callable([])) print(callable("dfsd")) # modules should not be callabe -import sys +try: + import usys as sys +except ImportError: + import sys print(callable(sys)) # builtins should be callable diff --git a/tests/basics/builtin_dir.py b/tests/basics/builtin_dir.py index 1eecbd044b..1f2b498d77 100644 --- a/tests/basics/builtin_dir.py +++ b/tests/basics/builtin_dir.py @@ -4,7 +4,10 @@ print('__name__' in dir()) # dir of module -import sys +try: + import usys as sys +except ImportError: + import sys print('version' in dir(sys)) # dir of type diff --git a/tests/basics/int_big1.py b/tests/basics/int_big1.py index 40d16c455b..108e3ee5c9 100644 --- a/tests/basics/int_big1.py +++ b/tests/basics/int_big1.py @@ -102,7 +102,10 @@ x = 4611686018427387904 # big x = -4611686018427387904 # big # sys.maxsize is a constant mpz, so test it's compatible with dynamic ones -import sys +try: + import usys as sys +except ImportError: + import sys print(sys.maxsize + 1 - 1 == sys.maxsize) # test extraction of big int value via mp_obj_get_int_maybe diff --git a/tests/basics/module2.py b/tests/basics/module2.py index a135601579..5923a27e08 100644 --- a/tests/basics/module2.py +++ b/tests/basics/module2.py @@ -1,6 +1,6 @@ # uPy behaviour only: builtin modules are read-only -import sys +import usys try: - sys.x = 1 + usys.x = 1 except AttributeError: print("AttributeError") diff --git a/tests/basics/python34.py b/tests/basics/python34.py index 4030db143c..0f6e4bafd0 100644 --- a/tests/basics/python34.py +++ b/tests/basics/python34.py @@ -33,9 +33,9 @@ test_syntax("del ()") # can't delete empty tuple (in 3.6 we can) # from basics/sys1.py # uPy prints version 3.4 -import sys -print(sys.version[:3]) -print(sys.version_info[0], sys.version_info[1]) +import usys +print(usys.version[:3]) +print(usys.version_info[0], usys.version_info[1]) # from basics/exception1.py # in 3.7 no comma is printed if there is only 1 arg (in 3.4-3.6 one is printed) diff --git a/tests/basics/string_compare.py b/tests/basics/string_compare.py index 6515809b36..f34879df25 100644 --- a/tests/basics/string_compare.py +++ b/tests/basics/string_compare.py @@ -51,7 +51,10 @@ print("1/" <= "1") # this tests an internal string that doesn't have a hash with a string # that does have a hash, but the lengths of the two strings are different -import sys +try: + import usys as sys +except ImportError: + import sys print(sys.version == 'a long string that has a hash') # this special string would have a hash of 0 but is incremented to 1 diff --git a/tests/basics/sys1.py b/tests/basics/sys1.py index 095824afaf..0947ea1964 100644 --- a/tests/basics/sys1.py +++ b/tests/basics/sys1.py @@ -1,6 +1,9 @@ # test sys module -import sys +try: + import usys as sys +except ImportError: + import sys print(sys.__name__) print(type(sys.path)) diff --git a/tests/basics/sys_exit.py b/tests/basics/sys_exit.py index b1f71549db..4d640ae60e 100644 --- a/tests/basics/sys_exit.py +++ b/tests/basics/sys_exit.py @@ -1,6 +1,9 @@ # test sys module's exit function -import sys +try: + import usys as sys +except ImportError: + import sys try: sys.exit diff --git a/tests/basics/sys_getsizeof.py b/tests/basics/sys_getsizeof.py index fe1b403e04..4dc919848c 100644 --- a/tests/basics/sys_getsizeof.py +++ b/tests/basics/sys_getsizeof.py @@ -1,6 +1,9 @@ # test sys.getsizeof() function -import sys +try: + import usys as sys +except ImportError: + import sys try: sys.getsizeof except AttributeError: |