def test_replacements_parsed(self): with self.write_config_file() as config: config.write("replace: {'[xy]': z}") self.run_command('test', lib=None) replacements = self.test_cmd.lib.replacements self.assertEqual(replacements, [(re.compile(u'[xy]'), 'z')])
def test_replacements_parsed(self): with self.write_config_file() as config: config.write("replace: {'[xy]': z}") ui._raw_main(["test"]) replacements = self.test_cmd.lib.replacements self.assertEqual(replacements, [(re.compile(r"[xy]"), b"z")])
def test_replacements_parsed(self): with self.write_config_file() as config: config.write("replace: {'[xy]': z}") ui._raw_main(['test']) replacements = self.test_cmd.lib.replacements self.assertEqual(replacements, [(re.compile(ur'[xy]'), b'z')])
def test_multiple_replacements_parsed(self): with self.write_config_file() as config: config.write("replace: {'[xy]': z, foo: bar}") ui._raw_main(["test"]) replacements = self.test_cmd.lib.replacements self.assertEqual(replacements, [(re.compile(ur"[xy]"), u"z"), (re.compile(ur"foo"), u"bar")])
def test_replacements_parsed(self): with self.write_config_file() as config: config.write("replace: {'[xy]': z}") ui._raw_main(['test']) replacements = self.test_cmd.lib.replacements self.assertEqual(replacements, [(re.compile(ur'[xy]'), u'z')])
def test_paths_section_respected(self): with self.write_config_file() as config: config.write('paths: {x: y}') ui._raw_main(['test']) key, template = self.test_cmd.lib.path_formats[0] self.assertEqual(key, 'x') self.assertEqual(template.original, 'y')
def test_paths_section_respected(self): with self.write_config_file() as config: config.write('paths: {x: y}') self.run_command('test', lib=None) key, template = self.test_cmd.lib.path_formats[0] self.assertEqual(key, 'x') self.assertEqual(template.original, 'y')
def test_replacements_parsed(self): with self.write_config_file() as config: config.write("replace: {'[xy]': z}") self.run_command('test', lib=None) replacements = self.test_cmd.lib.replacements repls = [(p.pattern, s) for p, s in replacements] # Compare patterns. self.assertEqual(repls, [(u'[xy]', 'z')])
def test_paths_section_respected(self): with self.write_config_file() as config: config.write("paths: {x: y}") ui._raw_main(["test"]) key, template = self.test_cmd.lib.path_formats[0] self.assertEqual(key, "x") self.assertEqual(template.original, "y")
def test_multiple_replacements_parsed(self): with self.write_config_file() as config: config.write("replace: {'[xy]': z, foo: bar}") self.run_command('test', lib=None) replacements = self.test_cmd.lib.replacements self.assertEqual(replacements, [ (re.compile(u'[xy]'), u'z'), (re.compile(u'foo'), u'bar'), ])
def test_multiple_replacements_parsed(self): with self.write_config_file() as config: config.write("replace: {'[xy]': z, foo: bar}") self.run_command('test', lib=None) replacements = self.test_cmd.lib.replacements repls = [(p.pattern, s) for p, s in replacements] self.assertEqual(repls, [ (u'[xy]', u'z'), (u'foo', u'bar'), ])
def test_multiple_replacements_parsed(self): with self.write_config_file() as config: config.write("replace: {'[xy]': z, foo: bar}") ui._raw_main(['test']) replacements = self.test_cmd.lib.replacements self.assertEqual(replacements, [ (re.compile(ur'[xy]'), u'z'), (re.compile(ur'foo'), u'bar'), ])
def test_multiple_replacements_parsed(self): with self.write_config_file() as config: config.write("replace: {'[xy]': z, foo: bar}") ui._raw_main(['test']) replacements = self.test_cmd.lib.replacements self.assertEqual(replacements, [ (re.compile(u'[xy]'), u'z'), (re.compile(u'foo'), u'bar'), ])
def test_default_paths_preserved(self): default_formats = ui.get_path_formats() self._reset_config() with self.write_config_file() as config: config.write('paths: {x: y}') self.run_command('test', lib=None) key, template = self.test_cmd.lib.path_formats[0] self.assertEqual(key, 'x') self.assertEqual(template.original, 'y') self.assertEqual(self.test_cmd.lib.path_formats[1:], default_formats)
def test_default_paths_preserved(self): default_formats = ui.get_path_formats() self._reset_config() with self.write_config_file() as config: config.write("paths: {x: y}") ui._raw_main(["test"]) key, template = self.test_cmd.lib.path_formats[0] self.assertEqual(key, "x") self.assertEqual(template.original, "y") self.assertEqual(self.test_cmd.lib.path_formats[1:], default_formats)
def test_nonexistant_db(self): with self.write_config_file() as config: config.write('library: /xxx/yyy/not/a/real/path') with self.assertRaises(ui.UserError): ui._raw_main(['test'])
def test_nonexistant_db(self): with self.write_config_file() as config: config.write('library: /xxx/yyy/not/a/real/path') with self.assertRaises(ui.UserError): self.run_command('test', lib=None)