Skip to content

Require compare-locales in fluent.migrate #47

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 7, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions fluent/migrate/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,7 @@
from fluent.syntax.parser import FluentParser
from fluent.syntax.serializer import FluentSerializer
from fluent.util import fold
try:
from compare_locales.parser import getParser
except ImportError:
def getParser(path):
raise RuntimeError('compare-locales required')
from compare_locales.parser import getParser

from .cldr import get_plural_categories
from .transforms import Source
Expand Down
3 changes: 2 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,6 @@
package_data={
'fluent.migrate': ['cldr_data/*']
},
tests_require=['six']
tests_require=['six'],
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried adding compare-locales here but python setup.py test fails with version conflicts when it tries to install it. compare-locales requires fluent==0.4.4 while python-fluent's master is usually newer than that.

test_suite='tests.syntax'
)
10 changes: 1 addition & 9 deletions tests/migrate/test_concat.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,9 @@
from __future__ import unicode_literals

import unittest
from compare_locales.parser import PropertiesParser, DTDParser

import fluent.syntax.ast as FTL
try:
from compare_locales.parser import PropertiesParser, DTDParser
except ImportError:
DTDParser = PropertiesParser = None

from fluent.migrate.util import parse, ftl_message_to_json
from fluent.migrate.helpers import EXTERNAL_ARGUMENT, MESSAGE_REFERENCE
from fluent.migrate.transforms import evaluate, CONCAT, COPY, REPLACE
Expand All @@ -23,7 +19,6 @@ def get_source(self, path, key):
return self.strings.get(key, None).val


@unittest.skipUnless(PropertiesParser, 'compare-locales required')
class TestConcatCopy(MockContext):
def setUp(self):
self.strings = parse(PropertiesParser, '''
Expand Down Expand Up @@ -120,7 +115,6 @@ def test_concat_whitespace_end(self):
)


@unittest.skipUnless(DTDParser, 'compare-locales required')
class TestConcatLiteral(MockContext):
def setUp(self):
self.strings = parse(DTDParser, '''
Expand Down Expand Up @@ -149,7 +143,6 @@ def test_concat_literal(self):
)


@unittest.skipUnless(DTDParser, 'compare-locales required')
class TestConcatInterpolate(MockContext):
def setUp(self):
self.strings = parse(DTDParser, '''
Expand Down Expand Up @@ -192,7 +185,6 @@ def test_concat_expression(self):
)


@unittest.skipUnless(DTDParser, 'compare-locales required')
class TestConcatReplace(MockContext):
def setUp(self):
self.strings = parse(DTDParser, '''
Expand Down
11 changes: 1 addition & 10 deletions tests/migrate/test_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,9 @@
import os
import logging
import unittest

try:
import compare_locales
except ImportError:
compare_locales = None
import compare_locales

import fluent.syntax.ast as FTL

from fluent.migrate.errors import (
EmptyLocalizationError, NotSupportedError, UnreadableReferenceError)
from fluent.migrate.util import ftl, ftl_resource_to_json, to_json
Expand All @@ -24,7 +19,6 @@ def here(*parts):
return os.path.join(dirname, *parts)


@unittest.skipUnless(compare_locales, 'compare-locales requried')
class TestMergeContext(unittest.TestCase):
def setUp(self):
self.ctx = MergeContext(
Expand Down Expand Up @@ -250,7 +244,6 @@ def test_missing_reference_file(self):
self.ctx.add_transforms('some.ftl', 'missing.ftl', [])


@unittest.skipUnless(compare_locales, 'compare-locales requried')
class TestMissingLocalizationFiles(unittest.TestCase):
def setUp(self):
# Silence all logging.
Expand Down Expand Up @@ -313,7 +306,6 @@ def test_all_files_missing(self):
])


@unittest.skipUnless(compare_locales, 'compare-locales requried')
class TestMissingLocalizationStrings(unittest.TestCase):
maxDiff = None

Expand Down Expand Up @@ -528,7 +520,6 @@ def test_missing_string_in_one_of_attributes(self):
)


@unittest.skipUnless(compare_locales, 'compare-locales requried')
class TestExistingTarget(unittest.TestCase):
maxDiff = None

Expand Down
9 changes: 1 addition & 8 deletions tests/migrate/test_context_real_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,9 @@

import os
import unittest

try:
import compare_locales
except ImportError:
compare_locales = None
import compare_locales

import fluent.syntax.ast as FTL

from fluent.migrate.util import ftl_resource_to_json, to_json
from fluent.migrate.context import MergeContext
from fluent.migrate.helpers import EXTERNAL_ARGUMENT, MESSAGE_REFERENCE
Expand All @@ -24,7 +19,6 @@ def here(*parts):
return os.path.join(dirname, *parts)


@unittest.skipUnless(compare_locales, 'compare-locales requried')
class TestMergeAboutDownloads(unittest.TestCase):
def setUp(self):
self.ctx = MergeContext(
Expand Down Expand Up @@ -279,7 +273,6 @@ def test_merge_context_some_messages(self):
)


@unittest.skipUnless(compare_locales, 'compare-locales requried')
class TestMergeAboutDialog(unittest.TestCase):
maxDiff = None

Expand Down
8 changes: 1 addition & 7 deletions tests/migrate/test_copy.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,9 @@
from __future__ import unicode_literals

import unittest
from compare_locales.parser import PropertiesParser, DTDParser

import fluent.syntax.ast as FTL
try:
from compare_locales.parser import PropertiesParser, DTDParser
except ImportError:
PropertiesParser = DTDParser = None

from fluent.migrate.util import parse, ftl_message_to_json
from fluent.migrate.transforms import evaluate, COPY

Expand All @@ -20,7 +16,6 @@ def get_source(self, path, key):
return self.strings.get(key, None).val


@unittest.skipUnless(PropertiesParser, 'compare-locales required')
class TestCopy(MockContext):
def setUp(self):
self.strings = parse(PropertiesParser, '''
Expand Down Expand Up @@ -71,7 +66,6 @@ def test_copy_escape_unicode_end(self):
)


@unittest.skipUnless(DTDParser, 'compare-locales required')
class TestCopyAttributes(MockContext):
def setUp(self):
self.strings = parse(DTDParser, '''
Expand Down
12 changes: 1 addition & 11 deletions tests/migrate/test_merge.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,10 @@
from __future__ import unicode_literals

import unittest
from compare_locales.parser import PropertiesParser, DTDParser

import fluent.syntax.ast as FTL
from fluent.syntax.parser import FluentParser
try:
from compare_locales.parser import PropertiesParser, DTDParser
except ImportError:
PropertiesParser = DTDParser = None

from fluent.migrate.util import parse, ftl, ftl_resource_to_json
from fluent.migrate.merge import merge_resource
from fluent.migrate.transforms import COPY
Expand All @@ -25,8 +21,6 @@ def get_source(self, path, key):
return translation.val


@unittest.skipUnless(PropertiesParser and DTDParser,
'compare-locales required')
class TestMergeMessages(MockContext):
maxDiff = None

Expand Down Expand Up @@ -129,8 +123,6 @@ def test_merge_three_way(self):
)


@unittest.skipUnless(PropertiesParser and DTDParser,
'compare-locales required')
class TestMergeAllEntries(MockContext):
def setUp(self):
self.en_us_ftl = parse(FluentParser, ftl('''
Expand Down Expand Up @@ -245,8 +237,6 @@ def test_merge_three_way(self):
)


@unittest.skipUnless(PropertiesParser and DTDParser,
'compare-locales required')
class TestMergeSubset(MockContext):
def setUp(self):
self.en_us_ftl = parse(FluentParser, ftl('''
Expand Down
11 changes: 1 addition & 10 deletions tests/migrate/test_plural.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,9 @@
from __future__ import unicode_literals

import unittest
from compare_locales.parser import PropertiesParser

import fluent.syntax.ast as FTL
try:
from compare_locales.parser import PropertiesParser
except ImportError:
PropertiesParser = None

from fluent.migrate.util import parse, ftl_message_to_json
from fluent.migrate.helpers import EXTERNAL_ARGUMENT
from fluent.migrate.transforms import evaluate, PLURALS, REPLACE_IN_TEXT
Expand All @@ -25,7 +21,6 @@ def get_source(self, path, key):
return self.strings.get(key, None).val


@unittest.skipUnless(PropertiesParser, 'compare-locales required')
class TestPlural(MockContext):
def setUp(self):
self.strings = parse(PropertiesParser, '''
Expand Down Expand Up @@ -79,7 +74,6 @@ def test_plural_too_many_variants(self):
)


@unittest.skipUnless(PropertiesParser, 'compare-locales required')
class TestPluralLiteral(MockContext):
def setUp(self):
self.strings = parse(PropertiesParser, '''
Expand Down Expand Up @@ -108,7 +102,6 @@ def test_plural_literal(self):
)


@unittest.skipUnless(PropertiesParser, 'compare-locales required')
class TestPluralReplace(MockContext):
def setUp(self):
self.strings = parse(PropertiesParser, '''
Expand Down Expand Up @@ -143,7 +136,6 @@ def test_plural_replace(self):
)


@unittest.skipUnless(PropertiesParser, 'compare-locales required')
class TestOneCategory(MockContext):
# Plural categories corresponding to Turkish (tr).
plural_categories = ('other',)
Expand Down Expand Up @@ -177,7 +169,6 @@ def test_no_select_expression(self):
)


@unittest.skipUnless(PropertiesParser, 'compare-locales required')
class TestManyCategories(MockContext):
# Plural categories corresponding to Polish (pl).
plural_categories = ('one', 'few', 'many', 'other')
Expand Down
7 changes: 1 addition & 6 deletions tests/migrate/test_replace.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,9 @@
from __future__ import unicode_literals

import unittest
from compare_locales.parser import PropertiesParser

import fluent.syntax.ast as FTL
try:
from compare_locales.parser import PropertiesParser
except ImportError:
PropertiesParser = None

from fluent.migrate.util import parse, ftl_message_to_json
from fluent.migrate.helpers import EXTERNAL_ARGUMENT
from fluent.migrate.transforms import evaluate, REPLACE
Expand All @@ -23,7 +19,6 @@ def get_source(self, path, key):
return self.strings.get(key, None).val


@unittest.skipUnless(PropertiesParser, 'compare-locales required')
class TestReplace(MockContext):
def setUp(self):
self.strings = parse(PropertiesParser, '''
Expand Down
9 changes: 1 addition & 8 deletions tests/migrate/test_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,9 @@
from __future__ import unicode_literals

import unittest

try:
from compare_locales.parser import PropertiesParser, DTDParser
except ImportError:
PropertiesParser = DTDParser = None
from compare_locales.parser import PropertiesParser, DTDParser

import fluent.syntax.ast as FTL

from fluent.migrate.errors import NotSupportedError
from fluent.migrate.transforms import Source, COPY, PLURALS, REPLACE
from fluent.migrate.util import parse
Expand Down Expand Up @@ -63,7 +58,6 @@ def get_source(self, _path, key):
return self.strings[key].val


@unittest.skipUnless(PropertiesParser, 'compare-locales required')
class TestProperties(MockContext):
def setUp(self):
self.strings = parse(PropertiesParser, '''
Expand Down Expand Up @@ -97,7 +91,6 @@ def test_html_entity(self):
self.assertEqual(source(self), '<⇧⌘K>')


@unittest.skipUnless(DTDParser, 'compare-locales required')
class TestDTD(MockContext):
def setUp(self):
self.strings = parse(DTDParser, '''
Expand Down
11 changes: 8 additions & 3 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,13 @@ skipsdist=True
[testenv]
setenv =
PYTHONPATH = {toxinidir}
deps = six
commands = python -m unittest discover -s tests/syntax

[testenv:py27-cl]
deps =
six
cl: compare-locales

commands=python -m unittest discover
compare-locales
commands =
python -m unittest discover -s tests/syntax
python -m unittest discover -s tests/migrate