Skip to content

Commit 180ec22

Browse files
ypyfcoolreader18
authored andcommitted
Add constants to os module (RustPython#883)
1 parent 6e867ed commit 180ec22

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

Lib/os.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,19 @@
11
from _os import *
22

3+
curdir = '.'
4+
pardir = '..'
5+
extsep = '.'
6+
37
if name == 'nt':
48
sep = '\\'
9+
linesep = '\r\n'
10+
altsep = '/'
11+
pathsep = ';'
512
else:
613
sep = '/'
14+
linesep = '\n'
15+
altsep = None
16+
pathsep = ':'
717

818
# Change environ to automatically call putenv(), unsetenv if they exist.
919
from _collections_abc import MutableMapping

tests/snippets/stdlib_os.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,20 @@
3333
os.unsetenv(ENV_KEY)
3434
assert os.getenv(ENV_KEY) == None
3535

36+
assert os.curdir == "."
37+
assert os.pardir == ".."
38+
assert os.extsep == "."
3639

3740
if os.name == "nt":
3841
assert os.sep == "\\"
42+
assert os.linesep == "\r\n"
43+
assert os.altsep == "/"
44+
assert os.pathsep == ";"
3945
else:
4046
assert os.sep == "/"
47+
assert os.linesep == "\n"
48+
assert os.altsep == None
49+
assert os.pathsep == ":"
4150

4251
class TestWithTempDir():
4352
def __enter__(self):

0 commit comments

Comments
 (0)