Skip to content

Commit d5b4415

Browse files
committed
more tests and globals
1 parent b78586a commit d5b4415

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

os/os.module.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,14 @@ func getlinesep() py.String {
5050
return py.String("\n")
5151
}
5252

53+
// getdefpath returns the default search path for executables. This is ':/bin:/usr/bin' in posix and 'C:\\bin' in windows
54+
func getdefpath() py.String {
55+
if runtime.GOOS == "windows" {
56+
return py.String("C:\\bin")
57+
}
58+
return py.String(":/bin:/usr/bin")
59+
}
60+
5361
func init() {
5462
methods := []*py.Method{
5563
py.MustNewMethod("getcwd", getCwd, 0, "Get the current working directory"),
@@ -73,6 +81,7 @@ func init() {
7381
"altsep": py.None,
7482
"pathsep": getpathsep(),
7583
"linesep": getlinesep(),
84+
"defpath": getdefpath(),
7685
}
7786

7887
py.RegisterModule(&py.ModuleImpl{

os/os.test.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,16 @@ def _fail(test_name):
188188
_fail("os.pathsep corresponding with os.name")
189189
failed+=1
190190

191+
if os.linesep == "\n" and os.name == "posix":
192+
_pass('os.linesep == "\\n" and os.name == "posix"')
193+
passed_tests+=1
194+
elif os.linesep == "\r\n" and os.name == "nt":
195+
_pass('os.linesep == "\\r\\n" and os.name == "nt"')
196+
passed_tests+=1
197+
else:
198+
_fail("os.linesep corresponding with os.name")
199+
failed+=1
200+
191201
print()
192202
print(bcolors.ENDC+bcolors.BOLD+bcolors.HEADER+"Please check if $HOME will be outputted...")
193203
print(bcolors.ENDC)

0 commit comments

Comments
 (0)