-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from django-ftl/fluent-compiler-next
Use fluent_compiler 0.2
- Loading branch information
Showing
15 changed files
with
217 additions
and
76 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[pytest] | ||
DJANGO_SETTINGS_MODULE = tests.settings |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,3 +6,4 @@ flake8-future-import>=0.4.5 | |
django-functest==1.0.4 | ||
check-manifest | ||
isort | ||
testfixtures |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
To run the benchmarks, do the following (assuming cwd at top level): | ||
|
||
$ pip install -r tests/benchmarks/requirements.txt | ||
|
||
Then, run the benchmarks as a script: | ||
|
||
$ ./tests/benchmarks/benchmarks.py | ||
|
||
You can also run them using py.test: | ||
|
||
$ py.test --benchmark-warmup=on tests/benchmarks/benchmarks.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
#!/usr/bin/env python | ||
|
||
# A set of benchmarks, generally used to test out different implementation | ||
# choices against each other. | ||
|
||
# This should be run using pytest, see end of file | ||
from __future__ import absolute_import, print_function, unicode_literals | ||
|
||
import os | ||
import subprocess | ||
import sys | ||
|
||
import pytest | ||
|
||
from django_ftl import activate | ||
from django_ftl.bundles import Bundle | ||
|
||
this_file = os.path.abspath(__file__) | ||
|
||
|
||
# For testing changes, can use multiple runs and compare mean or OPS figures on | ||
# subsequent runs, or test at the same time by creating multiple `Bundle` | ||
# implementations and add them to `params` below. | ||
|
||
@pytest.fixture(params=[Bundle]) | ||
def bundle(request): | ||
return request.param(['benchmarks/benchmarks.ftl'], default_locale='en') | ||
|
||
|
||
def test_simple_string_default_locale_present(bundle, benchmark): | ||
activate('en') | ||
result = benchmark(lambda: bundle.format('simple-string')) | ||
assert result == "Hello I am a simple string" | ||
|
||
|
||
def test_simple_string_other_locale_present(bundle, benchmark): | ||
activate('tr') | ||
result = benchmark(lambda: bundle.format('simple-string')) | ||
assert result == "Merhaba ben basit bir metinim" | ||
|
||
|
||
def test_simple_string_present_in_fallback(bundle, benchmark): | ||
activate('tr') | ||
result = benchmark(lambda: bundle.format('simple-string-present-in-fallback')) | ||
assert result == "Hello I am a simple string present in fallback" | ||
|
||
|
||
if __name__ == '__main__': | ||
# You can execute this file directly, and optionally add more py.test args | ||
# to the command line (e.g. -k for keyword matching certain tests). | ||
subprocess.check_call(["py.test", "--benchmark-warmup=on", "--benchmark-sort=name", this_file] + sys.argv[1:]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
pytest | ||
pytest-benchmark | ||
pytest-django |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
simple-string = Hello I am a simple string | ||
simple-string-present-in-fallback = Hello I am a simple string present in fallback |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
simple-string = Merhaba ben basit bir metinim |
Oops, something went wrong.