Skip to content

Commit

Permalink
Merge branch 'master' into fix-test-bisect
Browse files Browse the repository at this point in the history
  • Loading branch information
masayukig authored Oct 6, 2017
2 parents 0c6748f + 3ba9216 commit daa01b9
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
2 changes: 1 addition & 1 deletion stestr/commands/load.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ def load(force_init=False, in_streams=None,
opener = functools.partial(open, mode='rb')
streams = map(opener, streams)
else:
streams = [sys.stdin.buffer]
streams = [sys.stdin]

def mktagger(pos, result):
return testtools.StreamTagger([result], add=['worker-%d' % pos])
Expand Down
22 changes: 17 additions & 5 deletions stestr/tests/test_return_codes.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,17 @@ def setUp(self):
os.chdir(self.directory)
subprocess.call('stestr init', shell=True)

def assertRunExit(self, cmd, expected, subunit=False):
p = subprocess.Popen(
"%s" % cmd, shell=True,
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
out, err = p.communicate()
def assertRunExit(self, cmd, expected, subunit=False, stdin=None):
if stdin:
p = subprocess.Popen(
"%s" % cmd, shell=True, stdin=subprocess.PIPE,
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
out, err = p.communicate(stdin)
else:
p = subprocess.Popen(
"%s" % cmd, shell=True,
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
out, err = p.communicate()

if not subunit:
self.assertEqual(
Expand Down Expand Up @@ -187,3 +193,9 @@ def test_combine_results(self):
# The test results from running the same tests twice with combine
# should return a test count 2x as big at the end of the run
self.assertEqual(test_count * 2, combine_test_count)

def test_load_from_stdin(self):
self.assertRunExit('stestr run passing', 0)
stream = self._get_cmd_stdout(
'stestr last --subunit')[0]
self.assertRunExit('stestr load', 0, stdin=stream)

0 comments on commit daa01b9

Please sign in to comment.