Skip to content

Commit

Permalink
Merge branch 'release-1.12.8'
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew Moffat committed Dec 16, 2016
2 parents ba05d0f + 78c6b93 commit 4896a4c
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
@@ -1,5 +1,9 @@
# Changelog

## 1.12.8 - 12/16/16

* bugfix for patched glob.glob on python3.5 [#341](https://github.com/amoffat/sh/issues/341)

## 1.12.7 - 12/07/16

* added `_out` and `_out_bufsize` validator [#346](https://github.com/amoffat/sh/issues/346)
Expand Down
6 changes: 3 additions & 3 deletions sh.py
Expand Up @@ -24,7 +24,7 @@
#===============================================================================


__version__ = "1.12.7"
__version__ = "1.12.8"
__project_url__ = "https://github.com/amoffat/sh"


Expand Down Expand Up @@ -375,8 +375,8 @@ def __init__(self, path, results):
self.path = path
list.__init__(self, results)

def glob(path):
expanded = GlobResults(path, _old_glob(path))
def glob(path, *args, **kwargs):
expanded = GlobResults(path, _old_glob(path, *args, **kwargs))
return expanded

glob_module.glob = glob
Expand Down
25 changes: 25 additions & 0 deletions test.py
Expand Up @@ -131,10 +131,23 @@ def skip(*args, **kwargs):
return skip
return wrapper

def requires_progs(*progs):
missing = []
for prog in progs:
try:
sh.Command(prog)
except sh.CommandNotFound:
missing.append(prog)

friendly_missing = ", ".join(missing)
return skipUnless(len(missing) == 0, "Missing required system programs: %s"
% friendly_missing)

requires_posix = skipUnless(os.name == "posix", "Requires POSIX")
requires_utf8 = skipUnless(sh.DEFAULT_ENCODING == "UTF-8", "System encoding must be UTF-8")
not_osx = skipUnless(not IS_OSX, "Doesn't work on OSX")
requires_py3 = skipUnless(IS_PY3, "Test only works on Python 3")
requires_py35 = skipUnless(IS_PY3 and MINOR_VER >= 5, "Test only works on Python 3.5 or higher")


def create_tmp_test(code, prefix="tmp", delete=True, **kwargs):
Expand Down Expand Up @@ -266,6 +279,17 @@ def test_patched_glob(self):
out = python(py.name, files).strip()
self.assertEqual(out, "['*.faowjefoajweofj']")

@requires_py35
def test_patched_glob_with_recursive_argument(self):
from glob import glob

py = create_tmp_test("""
import sys
print(sys.argv[1:])
""")
files = glob("*.faowjefoajweofj", recursive=True)
out = python(py.name, files).strip()
self.assertEqual(out, "['*.faowjefoajweofj']")

def test_exit_code_with_hasattr(self):
from sh import ErrorReturnCode
Expand Down Expand Up @@ -2522,6 +2546,7 @@ def test_percent_doesnt_fail_logging(self):
# for some reason, i can't get a good stable baseline measured in this test
# on osx. so skip it for now if osx
@not_osx
@requires_progs("lsof")
def test_no_fd_leak(self):
import sh
import os
Expand Down

0 comments on commit 4896a4c

Please sign in to comment.