本文整理汇总了Python中tests.utils.stdin_as_string函数的典型用法代码示例。如果您正苦于以下问题:Python stdin_as_string函数的具体用法?Python stdin_as_string怎么用?Python stdin_as_string使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了stdin_as_string函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_geojson_no_inference
def test_geojson_no_inference(self):
input_file = six.StringIO(
'{"a": 1, "b": 2, "type": "FeatureCollection", "features": [{"geometry": {}, "properties": {"a": 1, "b": 2, "c": 3}}]}'
)
with stdin_as_string(input_file):
self.assertLines(["--no-inference", "-f", "geojson"], ["id,a,b,c,geojson", ",1,2,3,{}"])
开发者ID:sukic,项目名称:csvkit,代码行数:7,代码来源:test_geojson.py
示例2: test_ndjson_no_inference
def test_ndjson_no_inference(self):
input_file = six.StringIO('{"a": 1, "b": 2, "c": 3}')
with stdin_as_string(input_file):
self.assertLines(['--no-inference', '-f', 'ndjson'], [
'a,b,c',
'1,2,3',
])
开发者ID:sukic,项目名称:csvkit,代码行数:8,代码来源:test_in2csv.py
示例3: test_stdin_and_filename
def test_stdin_and_filename(self):
input_file = six.StringIO("a,b,c\n1,2,3\n")
with stdin_as_string(input_file):
sql = self.get_output(['-', 'examples/dummy.csv'])
self.assertTrue('CREATE TABLE stdin' in sql)
self.assertTrue('CREATE TABLE dummy' in sql)
开发者ID:andrewluetgers,项目名称:csvkit,代码行数:8,代码来源:test_csvsql.py
示例4: test_query_empty
def test_query_empty(self):
input_file = six.StringIO()
with stdin_as_string(input_file):
output = self.get_output(['--query', 'SELECT 1'])
self.assertEqual(output, '1\n1\n')
input_file.close()
开发者ID:datamade,项目名称:csvkit,代码行数:8,代码来源:test_csvsql.py
示例5: test_csv_datetime_inference
def test_csv_datetime_inference(self):
input_file = six.StringIO('a\n2015-01-01T00:00:00Z')
with stdin_as_string(input_file):
self.assertLines(['-f', 'csv'], [
'a',
'2015-01-01T00:00:00+00:00',
])
开发者ID:EMGMatt,项目名称:csvkit,代码行数:8,代码来源:test_in2csv.py
示例6: test_fixed_no_inference
def test_fixed_no_inference(self):
input_file = six.StringIO(' 1 2 3')
with stdin_as_string(input_file):
self.assertLines(['--no-inference', '-f', 'fixed', '--schema', 'examples/testfixed_schema_no_inference.csv'], [
'a,b,c',
'1,2,3',
])
开发者ID:EMGMatt,项目名称:csvkit,代码行数:8,代码来源:test_fixed.py
示例7: test_stdin_with_query
def test_stdin_with_query(self):
input_file = six.StringIO("select cast(3.1415 * 13.37 as integer) as answer")
with stdin_as_string(input_file):
csv = self.get_output(["--query", "select 6*9 as question"])
self.assertTrue("question" in csv)
self.assertTrue("42" not in csv)
开发者ID:JonCHodgson,项目名称:csvkit,代码行数:8,代码来源:test_sql2csv.py
示例8: test_escapechar
def test_escapechar(self):
input_file = six.StringIO('a,b,c\n1"2,3,4\n')
with stdin_as_string(input_file):
self.assertLines(['-P', '#', '-U', '3'], [
'a,b,c',
'1#"2,3,4',
])
开发者ID:JonCHodgson,项目名称:csvkit,代码行数:8,代码来源:test_csvformat.py
示例9: test_quoting
def test_quoting(self):
input_file = six.StringIO('a,b,c\n1*2,3,4\n')
with stdin_as_string(input_file):
self.assertLines(['-Q', '*', '-U', '0', '-B'], [
'a,b,c',
'*1**2*,3,4',
])
开发者ID:JonCHodgson,项目名称:csvkit,代码行数:8,代码来源:test_csvformat.py
示例10: test_stdin
def test_stdin(self):
input_file = six.StringIO('a,b,c\n4,5,6\n1,2,3\n')
with stdin_as_string(input_file):
self.assertLines([], [
'a,b,c',
'1,2,3',
'4,5,6',
])
开发者ID:Lewis-Liu,项目名称:csvkit,代码行数:9,代码来源:test_csvsort.py
示例11: test_empty_with_query
def test_empty_with_query(self):
input_file = six.StringIO()
with stdin_as_string(input_file):
output_file = six.StringIO()
utility = CSVSQL(['--query', 'select 1'], output_file)
utility.run()
output_file.close()
input_file.close()
开发者ID:skorasaurus,项目名称:csvkit,代码行数:10,代码来源:test_csvsql.py
示例12: test_doublequote
def test_doublequote(self):
input_file = six.StringIO('a\n"a ""quoted"" string"')
with stdin_as_string(input_file):
self.assertLines(['-P', '#', '-B'], [
'a',
'a #"quoted#" string',
])
input_file.close()
开发者ID:skorasaurus,项目名称:csvkit,代码行数:10,代码来源:test_csvformat.py
示例13: test_quotechar
def test_quotechar(self):
input_file = six.StringIO('a,b,c\n1*2,3,4\n')
with stdin_as_string(input_file):
self.assertLines(['-Q', '*'], [
'a,b,c',
'*1**2*,3,4',
])
input_file.close()
开发者ID:skorasaurus,项目名称:csvkit,代码行数:10,代码来源:test_csvformat.py
示例14: test_stdin
def test_stdin(self):
input_file = six.StringIO('a,b,c\n1,2,3\n')
with stdin_as_string(input_file):
sql = self.get_output(['--table', 'foo'])
self.assertTrue('CREATE TABLE foo' in sql)
self.assertTrue('a INTEGER NOT NULL' in sql)
self.assertTrue('b INTEGER NOT NULL' in sql)
self.assertTrue('c INTEGER NOT NULL' in sql)
开发者ID:andrewluetgers,项目名称:csvkit,代码行数:10,代码来源:test_csvsql.py
示例15: test_stdin_with_file_and_query
def test_stdin_with_file_and_query(self):
input_file = six.StringIO('select cast(3.1415 * 13.37 as integer) as answer')
with stdin_as_string(input_file):
csv = self.get_output(['examples/test.sql', '--query', 'select 6*9 as question'])
self.assertTrue('question' in csv)
self.assertTrue('54' in csv)
input_file.close()
开发者ID:datamade,项目名称:csvkit,代码行数:10,代码来源:test_sql2csv.py
示例16: test_stdin
def test_stdin(self):
output_file = StringIO()
input_file = StringIO("select cast(3.1415 * 13.37 as integer) as answer")
with stdin_as_string(input_file):
utility = SQL2CSV([], output_file)
utility.main()
csv = output_file.getvalue()
self.assertTrue("answer" in csv)
self.assertTrue("42" in csv)
开发者ID:pombredanne,项目名称:csvkit,代码行数:11,代码来源:test_sql2csv.py
示例17: test_stdin
def test_stdin(self):
input_file = six.StringIO('a,b,c\n4,2,3\n')
with stdin_as_string(input_file):
sql = self.get_output(['--tables', 'foo'])
self.assertTrue('CREATE TABLE foo' in sql)
self.assertTrue('a DECIMAL NOT NULL' in sql)
self.assertTrue('b DECIMAL NOT NULL' in sql)
self.assertTrue('c DECIMAL NOT NULL' in sql)
input_file.close()
开发者ID:skorasaurus,项目名称:csvkit,代码行数:12,代码来源:test_csvsql.py
示例18: test_stdin_with_query
def test_stdin_with_query(self):
args = ['--query', 'select 6*9 as question']
output_file = six.StringIO()
input_file = six.StringIO("select cast(3.1415 * 13.37 as integer) as answer")
with stdin_as_string(input_file):
utility = SQL2CSV(args, output_file)
utility.main()
csv = output_file.getvalue()
self.assertTrue('question' in csv)
self.assertTrue('42' not in csv)
开发者ID:haginara,项目名称:csvkit,代码行数:12,代码来源:test_sql2csv.py
示例19: test_query
def test_query(self):
input_file = six.StringIO("a,b,c\n1,2,3\n")
with stdin_as_string(input_file):
sql = self.get_output(['--query', 'SELECT m.usda_id, avg(i.sepal_length) AS mean_sepal_length FROM iris AS i JOIN irismeta AS m ON (i.species = m.species) GROUP BY m.species', 'examples/iris.csv', 'examples/irismeta.csv'])
self.assertTrue('usda_id,mean_sepal_length' in sql)
self.assertTrue('IRSE,5.00' in sql)
self.assertTrue('IRVE2,5.936' in sql)
self.assertTrue('IRVI,6.58' in sql)
input_file.close()
开发者ID:skorasaurus,项目名称:csvkit,代码行数:12,代码来源:test_csvsql.py
示例20: test_stdin_with_query
def test_stdin_with_query(self):
args = ["--query", "select 6*9 as question"]
output_file = StringIO()
input_file = StringIO("select cast(3.1415 * 13.37 as integer) as answer")
with stdin_as_string(input_file):
utility = SQL2CSV(args, output_file)
utility.main()
csv = output_file.getvalue()
self.assertTrue("question" in csv)
self.assertTrue("42" not in csv)
开发者ID:pombredanne,项目名称:csvkit,代码行数:12,代码来源:test_sql2csv.py
注:本文中的tests.utils.stdin_as_string函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论