def test_extract_from_files_no_file(self): """ If the file path doesn't exist, it should be skipped. """ testfile = ("lib/l10n_utils/tests/test_files/templates/" "file_does_not_exist.html",) with capture_stdio() as out: extracted = next(extract_from_files(testfile, method_map=METHODS), None) self.assertIsNone(extracted) self.assertEqual(out[0], "! %s does not exist!" % testfile)
def test_extract_from_files_no_match(self): """ If the file path doesn't match a domain method, it should be skipped. """ testfile = ("bedrock/mozorg/templates/mozorg/home.html",) with capture_stdio() as out: extracted = next(extract_from_files(testfile, method_map=METHODS), None) self.assertIsNone(extracted) self.assertEqual(out[0], "! %s does not match any domain methods!" % testfile)
def test_extract_from_files_no_file(self): """ If the file path doesn't exist, it should be skipped. """ testfile = ('templates/file_does_not_exist.html', ) with capture_stdio() as out: extracted = next(extract_from_files(testfile, method_map=METHODS), None) self.assertIsNone(extracted) self.assertEqual(out[0], '! %s does not exist!' % testfile)
def test_extract_from_files(self): """ Should be able to extract strings from a specific file. """ testfile = ("lib/l10n_utils/tests/test_files/templates/" "even_more_lang_files.html",) with capture_stdio() as out: extracted = next(extract_from_files(testfile, method_map=METHODS)) self.assertTupleEqual(extracted, (testfile[0], 9, "Mark it 8 Dude.", [])) # test default callback self.assertEqual(out[0], " %s" % testfile)
def test_extract_from_files(self): """ Should be able to extract strings from a specific file. """ testfile = ('templates/even_more_lang_files.html',) with capture_stdio() as out: extracted = next(extract_from_files(testfile, method_map=METHODS)) self.assertTupleEqual(extracted, (testfile[0], 9, 'Mark it 8 Dude.', [], None)) # test default callback self.assertEqual(out[0], ' %s' % testfile)
def test_extract_from_files_no_match(self): """ If the file path doesn't match a domain method, it should be skipped. """ testfile = ('bedrock/mozorg/templates/mozorg/home.html',) with capture_stdio() as out: extracted = next(extract_from_files(testfile, method_map=METHODS), None) self.assertIsNone(extracted) self.assertEqual(out[0], '! %s does not match any domain methods!' % testfile)
def test_extract_from_multiple_files(self): """ Should be able to extract strings from specific files. """ basedir = "lib/l10n_utils/tests/test_files/templates/" testfiles = (basedir + "even_more_lang_files.html", basedir + "some_lang_files.html") good_extracts = ( (testfiles[0], 9, "Mark it 8 Dude.", []), (testfiles[1], 10, "Is this your homework Larry?", [u"Said angrily, loudly, and repeatedly."]), ) with capture_stdio() as out: for i, extracted in enumerate(extract_from_files(testfiles, method_map=METHODS)): self.assertTupleEqual(extracted, good_extracts[i]) self.assertEqual(out[0], " %s\n %s" % testfiles)
def test_extract_from_multiple_files(self): """ Should be able to extract strings from specific files. """ basedir = 'lib/l10n_utils/tests/test_files/templates/' testfiles = ( basedir + 'even_more_lang_files.html', basedir + 'some_lang_files.html', ) good_extracts = ( (testfiles[0], 9, 'Mark it 8 Dude.', []), (testfiles[1], 9, 'Is this your homework Larry?', []), ) with capture_stdio() as out: for i, extracted in enumerate( extract_from_files(testfiles, method_map=METHODS)): self.assertTupleEqual(extracted, good_extracts[i]) self.assertEqual(out[0], ' %s\n %s' % testfiles)