Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1210)

Unified Diff: recipe_modules/raw_io/example.py

Issue 2672593002: raw_io module: Add text_input and text_output (Closed)
Patch Set: Add comment about no cover Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « recipe_modules/raw_io/api.py ('k') | recipe_modules/raw_io/example.expected/basic.json » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: recipe_modules/raw_io/example.py
diff --git a/recipe_modules/raw_io/example.py b/recipe_modules/raw_io/example.py
index 6c565de4577477c4529d9f15fa39674f4ffc207f..11c308d444241e9bf3db45086ed00a8c17ce8ad3 100644
--- a/recipe_modules/raw_io/example.py
+++ b/recipe_modules/raw_io/example.py
@@ -21,10 +21,21 @@ def RunSteps(api):
# Pass stuff to command's stdin, read it from stdout.
step_result = api.step('cat', ['cat'],
- stdin=api.raw_io.input(data='hello'),
+ stdin=api.raw_io.input_text(data='hello'),
stdout=api.raw_io.output('out'))
assert step_result.stdout == 'hello'
+ step_result = api.step('cat', ['cat', api.raw_io.input_text(data='hello')],
+ stdout=api.raw_io.output('out'))
+ assert step_result.stdout == 'hello'
+
+ # \xe2 is not encodable by utf-8 (and has shown up in actual recipe data)
+ # so test that input correctly doesn't try to encode it as utf-8.
+ step_result = api.step('cat', ['cat'],
+ stdin=api.raw_io.input(data='\xe2hello'),
+ stdout=api.raw_io.output())
+ assert step_result.stdout == '\xe2hello'
+
# Example of auto-mocking stdout. '\n' appended to mock 'echo' behavior.
step_result = api.step('automock', ['echo', 'huh'],
stdout=api.raw_io.output('out'),
@@ -66,11 +77,12 @@ def RunSteps(api):
with open(sys.argv[1], 'w') as f:
f.write(%r)
""" % api.properties.get('some_prop', 'good_value'),
- args=[api.raw_io.output(name='test')],
+ args=[api.raw_io.output_text(name='test')],
step_test_data=(
- lambda: api.raw_io.test_api.output('second_bad_value', name='test')))
- assert step_result.raw_io.outputs['test'] == 'good_value'
- assert step_result.raw_io.output == 'good_value'
+ lambda: api.raw_io.test_api.output_text(
+ 'second_bad_value', name='test')))
+ assert step_result.raw_io.output_texts['test'] == 'good_value'
+ assert step_result.raw_io.output_text == 'good_value'
def GenTests(api):
@@ -89,6 +101,10 @@ def GenTests(api):
stderr=api.raw_io.output('')) +
api.step_data('cat',
stdout=api.raw_io.output('hello')) +
+ api.step_data('cat (2)',
+ stdout=api.raw_io.output('hello')) +
+ api.step_data('cat (3)',
+ stdout=api.raw_io.output('\xe2hello')) +
api.step_data('override_default_mock',
- api.raw_io.output('good_value', name='test'))
+ api.raw_io.output_text('good_value', name='test'))
)
« no previous file with comments | « recipe_modules/raw_io/api.py ('k') | recipe_modules/raw_io/example.expected/basic.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698