本文整理汇总了Python中tests.create_file函数的典型用法代码示例。如果您正苦于以下问题:Python create_file函数的具体用法?Python create_file怎么用?Python create_file使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了create_file函数的18个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_it_should_delete_the_temporary_file_with_sparql_down_when_executing_change
def test_it_should_delete_the_temporary_file_with_sparql_down_when_executing_change(self, run_isql_mock, write_temporary_file_mock):
create_file('filename_down.ttl', 'content')
run_isql_mock.side_effect = command_call_side_effect
write_temporary_file_mock.side_effect = temp_file_side_effect
virtuoso = Virtuoso(self.config)
self.assertRaisesWithMessage(MigrationException, '\nerror executing migration statement: err\n\nRollback done successfully!!!', virtuoso.execute_change, "sparql_up", "sparql_down")
self.assertFalse(os.path.exists('filename_down.ttl'))
开发者ID:globocom,项目名称:simple-virtuoso-migrate,代码行数:8,代码来源:virtuoso_test.py
示例2: setUp
def setUp(self):
config_file = '''
DATABASE_HOST = 'localhost'
DATABASE_USER = 'root'
DATABASE_PASSWORD = ''
DATABASE_NAME = 'migration_example'
ENV1_DATABASE_NAME = 'migration_example_env1'
DATABASE_MIGRATIONS_DIR = 'example'
UTC_TIMESTAMP = True
DATABASE_ANY_CUSTOM_VARIABLE = 'Some Value'
SOME_ENV_DATABASE_ANY_CUSTOM_VARIABLE = 'Other Value'
DATABASE_OTHER_CUSTOM_VARIABLE = 'Value'
'''
create_file('sample.conf', config_file)
create_file('sample.py', "import os\n%s" % config_file)
开发者ID:icaromedeiros,项目名称:simple-virtuoso-migrate,代码行数:15,代码来源:helpers_test.py
示例3: setUp
def setUp(self):
config_file = '''
DATABASE_HOST = 'localhost'
DATABASE_USER = 'root'
DATABASE_PASSWORD = ''
DATABASE_PORT = 'port'
DATABASE_ENDPOINT = 'migration_example'
DATABASE_GRAPH = 'graph'
DATABASE_ONTOLOGY = 'ontology'
ENV1_DATABASE_ENDPOINT = 'migration_example_env1'
DATABASE_MIGRATIONS_DIR = 'example'
DATABASE_ANY_CUSTOM_VARIABLE = 'Some Value'
SOME_ENV_DATABASE_ANY_CUSTOM_VARIABLE = 'Other Value'
DATABASE_OTHER_CUSTOM_VARIABLE = 'Value'
'''
create_file('sample.conf', config_file)
开发者ID:viniciuschagas,项目名称:simple-virtuoso-migrate,代码行数:16,代码来源:run_test.py
示例4: setUp
def setUp(self):
super(MainTest, self).setUp()
self.initial_config = {
'database_host': 'localhost',
'database_port': 'port',
'database_endpoint': 'test',
'database_user': 'user',
'database_password': 'password',
'database_migrations_dir': '.',
'database_graph': 'graph',
'database_ontology': 'ontology.ttl',
'file_migration': None,
'show_sparql_only': None
}
create_file("ontology.ttl", "content")
开发者ID:icaromedeiros,项目名称:simple-virtuoso-migrate,代码行数:16,代码来源:main_test.py
示例5: setUp
def setUp(self):
super(MainTest, self).setUp()
self.initial_config = {
'database_host': 'localhost',
'database_port': 'port',
'database_endpoint': 'test',
'database_user': 'user',
'database_password': 'password',
'database_migrations_dir': '.',
'database_graph': 'graph',
'database_ontology': 'ontology.ttl',
'host_user': 'host-user',
'host_password': 'host-passwd',
'file_migration': None,
'migration_graph': 'http://example.com',
'show_sparql_only': None,
'virtuoso_dirs_allowed': '/tmp'
}
create_file("ontology.ttl", "content")
create_file("new_triple.ttl")
开发者ID:rodsenra,项目名称:simple-virtuoso-migrate,代码行数:21,代码来源:main_test.py
示例6: setUp
def setUp(self):
create_migration_file('20090214120600_example_file_name_test_migration.migration', sql_up='xxx', sql_down='yyy')
create_migration_file('20090727104700_test_migration.migration', sql_up='xxx', sql_down='yyy')
create_migration_file('20090727141400_test_migration.migration', sql_up='xxx', sql_down='yyy')
create_migration_file('20090727141503_test_migration.migration', sql_up='xxx', sql_down='yyy')
create_migration_file('20090727113900_empty_sql_up_test_migration.migration', sql_up='', sql_down='zzz')
create_migration_file('20090727113900_empty_sql_down_test_migration.migration', sql_up='zzz', sql_down='')
create_file('20090727114700_empty_file_test_migration.migration')
create_file('20090727114700_without_sql_down_test_migration.migration', 'SQL_UP=""')
create_file('20090727114700_without_sql_up_test_migration.migration', 'SQL_DOWN=""')
开发者ID:prestes,项目名称:simple-db-migrate,代码行数:10,代码来源:core_test.py
示例7: setUp
def setUp(self):
create_migration_file('20090214120600_example_file_name_test_migration.migration', sql_up='xxx', sql_down='yyy')
create_migration_file('20090727104700_test_migration.migration', sql_up='xxx', sql_down='yyy')
create_migration_file('20090727141400_test_migration.migration', sql_up='xxx', sql_down='yyy')
create_migration_file('20090727141503_test_migration.migration', sql_up='xxx', sql_down='yyy')
create_migration_file('20090727141505_01_test_migration.migration', sql_up='xxx', sql_down='yyy')
create_migration_file('20090727141505_02_test_migration.migration', sql_up='xxx', sql_down='yyy')
create_migration_file('20090727113900_empty_sql_up_test_migration.migration', sql_up='', sql_down='zzz')
create_migration_file('20090727113900_empty_sql_down_test_migration.migration', sql_up='zzz', sql_down='')
create_file('20090727114700_empty_file_test_migration.migration')
create_file('20090727114700_without_sql_down_test_migration.migration', 'SQL_UP=""')
create_file('20090727114700_without_sql_up_test_migration.migration', 'SQL_DOWN=""')
self.migration = Migration(label="generate_test_migration", version="20120101010100", sql_up="some_sql", sql_down="some_sql_down")
开发者ID:aoqfonseca,项目名称:simple-db-migrate,代码行数:13,代码来源:core_test.py
示例8: setUp
def setUp(self):
config_file = '''
DATABASE_HOST = 'localhost'
DATABASE_USER = 'root'
DATABASE_PASSWORD = ''
DATABASE_NAME = 'migration_example'
ENV1_DATABASE_NAME = 'migration_example_env1'
UTC_TIMESTAMP = True
DATABASE_ANY_CUSTOM_VARIABLE = 'Some Value'
SOME_ENV_DATABASE_ANY_CUSTOM_VARIABLE = 'Other Value'
DATABASE_OTHER_CUSTOM_VARIABLE = 'Value'
RUN_AFTER = './some_dummy_action.py'
RUN_AFTER_PARAMS = {'key': 'value'}
'''
create_file('sample.conf', "%s\nDATABASE_MIGRATIONS_DIR = 'example'" % config_file)
create_file('sample2.conf', "%s" % config_file)
create_file('sample.py', "import os\n%s\nDATABASE_MIGRATIONS_DIR = 'example'" % config_file)
开发者ID:globocom,项目名称:simple-virtuoso-migrate,代码行数:17,代码来源:config_test.py
示例9: test_it_should_get_sql_command_containing_non_ascii_characters_and_python_code_without_scope
def test_it_should_get_sql_command_containing_non_ascii_characters_and_python_code_without_scope(self):
file_name = '20090508155742_test_migration.migration'
create_file(file_name, content='SQL_UP=u"some sql command ç %s" % os.path.abspath(\'.\')\nSQL_DOWN=u"other sql command ã %s" % os.path.abspath(\'.\')'.decode('utf-8'))
migration = Migration(file_name)
self.assertEqual(u"some sql command ç %s" % os.path.abspath('.'), migration.sql_up)
self.assertEqual(u"other sql command ã %s" % os.path.abspath('.'), migration.sql_down)
开发者ID:guilhermechapiewski,项目名称:simple-db-migrate,代码行数:6,代码来源:core_test.py
示例10: test_it_should_get_sql_command_containing_non_ascii_characters
def test_it_should_get_sql_command_containing_non_ascii_characters(self):
file_name = '20090508155742_test_migration.migration'
create_file(file_name, content='SQL_UP=u"some sql command ç"\nSQL_DOWN=u"other sql command ã"'.decode('utf-8'))
migration = Migration(file_name)
self.assertEqual(u"some sql command ç", migration.sql_up)
self.assertEqual(u"other sql command ã", migration.sql_down)
开发者ID:guilhermechapiewski,项目名称:simple-db-migrate,代码行数:6,代码来源:core_test.py
示例11: test_it_should_get_sql_command_containing_unicode_characters_and_python_code
def test_it_should_get_sql_command_containing_unicode_characters_and_python_code(self):
file_name = '20090508155742_test_migration.migration'
create_file(file_name, content='import os\nSQL_UP=u"some sql command %s" % os.path.abspath(\'.\')\nSQL_DOWN=u"other sql command %s" % os.path.abspath(\'.\')')
migration = Migration(file_name)
self.assertEqual(u"some sql command %s" % os.path.abspath('.'), migration.sql_up)
self.assertEqual(u"other sql command %s" % os.path.abspath('.'), migration.sql_down)
开发者ID:guilhermechapiewski,项目名称:simple-db-migrate,代码行数:6,代码来源:core_test.py
示例12: test_it_should_get_sql_command_containing_unicode_characters
def test_it_should_get_sql_command_containing_unicode_characters(self):
file_name = '20090508155742_test_migration.migration'
create_file(file_name, content='SQL_UP=u"some sql command"\nSQL_DOWN=u"other sql command"')
migration = Migration(file_name)
self.assertEqual(u"some sql command", migration.sql_up)
self.assertEqual(u"other sql command", migration.sql_down)
开发者ID:guilhermechapiewski,项目名称:simple-db-migrate,代码行数:6,代码来源:core_test.py
示例13: test_it_should_delete_the_temporary_file_with_sparql_up_when_executing_change_raise_an_error
def test_it_should_delete_the_temporary_file_with_sparql_up_when_executing_change_raise_an_error(self, run_isql_mock, write_temporary_file_mock):
create_file('filename.ttl', 'content')
virtuoso = Virtuoso(self.config)
self.assertRaisesWithMessage(Exception, 'some error', virtuoso.execute_change, "sparql_up", "sparql_down")
self.assertFalse(os.path.exists('filename.ttl'))
开发者ID:globocom,项目名称:simple-virtuoso-migrate,代码行数:6,代码来源:virtuoso_test.py
示例14: setUp
def setUp(self):
super(VirtuosoTest, self).setUp()
self.config = Config()
self.config.put("database_migrations_dir", ".")
self.config.put("database_ontology", "test.ttl")
self.config.put("database_graph", "test")
self.config.put("database_host", "localhost")
self.config.put("database_user", "user")
self.config.put("database_password", "password")
self.config.put("database_port", 9999)
self.config.put("database_endpoint", "endpoint")
self.config.put("host_user", "host-user")
self.config.put("host_password", "host-passwd")
self.config.put("virtuoso_dirs_allowed", "/tmp")
self.config.put("migration_graph", "http://example.com/")
create_file("test.ttl", "")
self.data_ttl_content = """
@prefix : <http://example.com/> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
<http://example.com/John> rdf:type <http://example.com/Person>.
"""
create_file("data.ttl", self.data_ttl_content)
self.structure_01_ttl_content = """
@prefix : <http://example.com/> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
:Actor rdf:type owl:Class .
:SoapOpera rdf:type owl:Class .
"""
create_file("structure_01.ttl", self.structure_01_ttl_content)
self.structure_02_ttl_content = """
@prefix : <http://example.com/> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
:Actor rdf:type owl:Class .
:SoapOpera rdf:type owl:Class .
:RoleOnSoapOpera rdf:type owl:Class .
:role rdf:type owl:Class ;
rdfs:subClassOf [
rdf:type owl:Restriction ;
owl:onProperty :play_a_role ;
owl:onClass :RoleOnSoapOpera ;
owl:minQualifiedCardinality "1"^^xsd:nonNegativeInteger ;
owl:maxQualifiedCardinality "1"^^xsd:nonNegativeInteger
] .
"""
create_file("structure_02.ttl", self.structure_02_ttl_content)
self.structure_03_ttl_content = """
@prefix : <http://example.com/> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
:Actor rdf:type owl:Class .
:SoapOpera rdf:type owl:Class .
:RoleOnSoapOpera rdf:type owl:Class .
:role rdf:type owl:Class ;
rdfs:subClassOf [
rdf:type owl:Restriction ;
owl:onProperty :play_a_role ;
owl:onClass :RoleOnSoapOpera ;
owl:minQualifiedCardinality "1111"^^xsd:nonNegativeInteger
] ,
[
rdf:type owl:Restriction ;
owl:onProperty :play_a_role ;
owl:onClass :RoleOnSoapOpera ;
owl:maxQualifiedCardinality "3333"^^xsd:nonNegativeInteger
] .
"""
create_file("structure_03.ttl", self.structure_03_ttl_content)
self.structure_04_ttl_content = """
@prefix : <http://example.com/> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
#.........这里部分代码省略.........
开发者ID:globocom,项目名称:simple-virtuoso-migrate,代码行数:101,代码来源:virtuoso_test.py
示例15: test_it_should_use_file_size_as_the_command_buffer_size_on_isql_calls
def test_it_should_use_file_size_as_the_command_buffer_size_on_isql_calls(self, popen_mock, communicate_mock):
virtuoso = Virtuoso(self.config)
create_file("big_file.ttl", "0123456789" * 480000)
virtuoso._run_isql("big_file.ttl", True)
popen_mock.assert_called_with('isql -U user -P password -H localhost -S 9999 -b 4800 < "big_file.ttl"', shell=True, stderr=-1, stdout=-1)
开发者ID:globocom,项目名称:simple-virtuoso-migrate,代码行数:5,代码来源:virtuoso_test.py
示例16: test_it_should_get_sql_command_containing_non_ascii_characters_with_non_utf8_encoding
def test_it_should_get_sql_command_containing_non_ascii_characters_with_non_utf8_encoding(self):
file_name = '20090508155742_test_migration.migration'
create_file(file_name, content='SQL_UP=u"some sql command ç"\nSQL_DOWN=u"other sql command ã"'.decode('iso8859-1'), encoding='iso8859-1')
migration = Migration(file_name, script_encoding='iso8859-1')
self.assertEqual(u"some sql command \xc3\xa7", migration.sql_up)
self.assertEqual(u"other sql command \xc3\xa3", migration.sql_down)
开发者ID:guilhermechapiewski,项目名称:simple-db-migrate,代码行数:6,代码来源:core_test.py
示例17: create_file
def test_it_should_get_sql_command_containing_non_ascii_characters_and_python_code_without_scope_with_non_utf8_encoding(self):
file_name = '20090508155742_test_migration.migration'
create_file(file_name, content='SQL_UP=u"some sql command ç %s" % os.path.abspath(\'.\')\nSQL_DOWN=u"other sql command ã %s" % os.path.abspath(\'.\')'.decode('iso8859-1'), encoding='iso8859-1')
migration = Migration(file_name, script_encoding='iso8859-1')
self.assertEqual(u"some sql command \xc3\xa7 %s" % os.path.abspath('.'), migration.sql_up)
self.assertEqual(u"other sql command \xc3\xa3 %s" % os.path.abspath('.'), migration.sql_down)
开发者ID:guilhermechapiewski,项目名称:simple-db-migrate,代码行数:6,代码来源:core_test.py
示例18: test_it_should_delete_the_temporary_file_with_sparql_up_when_executing_change
def test_it_should_delete_the_temporary_file_with_sparql_up_when_executing_change(self, run_isql_mock, write_temporary_file_mock):
create_file('filename.ttl', 'content')
virtuoso = Virtuoso(self.config)
virtuoso.execute_change("sparql_up", "sparql_down")
self.assertFalse(os.path.exists('filename.ttl'))
开发者ID:globocom,项目名称:simple-virtuoso-migrate,代码行数:6,代码来源:virtuoso_test.py
注:本文中的tests.create_file函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论