本文整理汇总了Python中weblate.trans.tests.utils.get_test_file函数的典型用法代码示例。如果您正苦于以下问题:Python get_test_file函数的具体用法?Python get_test_file怎么用?Python get_test_file使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_test_file函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_extra_file
def test_extra_file(self):
"""
Test extra commit file handling.
"""
subproject = self.create_subproject()
subproject.pre_commit_script = get_test_file(
'../../../../examples/hook-generate-mo'
)
appsettings.PRE_COMMIT_SCRIPT_CHOICES.append(
(subproject.pre_commit_script, 'hook-generate-mo')
)
subproject.pre_commit_script = get_test_file(
'../../../../examples/hook-update-linguas'
)
appsettings.PRE_COMMIT_SCRIPT_CHOICES.append(
(subproject.pre_commit_script, 'hook-update-linguas')
)
subproject.extra_commit_file = 'po/%(language)s.mo\npo/LINGUAS'
subproject.save()
subproject.full_clean()
translation = subproject.translation_set.get(language_code='cs')
# change backend file
with open(translation.get_filename(), 'a') as handle:
handle.write(' ')
# Test committing
translation.git_commit(
None, 'TEST <[email protected]>', timezone.now(),
force_commit=True
)
linguas = os.path.join(subproject.get_path(), 'po', 'LINGUAS')
with open(linguas, 'r') as handle:
data = handle.read()
self.assertIn('\ncs\n', data)
self.assertFalse(translation.repo_needs_commit())
示例2: upload_file
def upload_file(self, name, **kwargs):
with open(get_test_file(name), 'rb') as handle:
return self.client.post(
reverse('memory-upload', **kwargs),
{'file': handle},
follow=True
)
示例3: test_import_map
def test_import_map(self):
call_command(
'import_memory',
get_test_file('memory.tmx'),
language_map='en_US:en',
)
self.assertEqual(TranslationMemory().doc_count(), 2)
示例4: test_import_json_command
def test_import_json_command(self):
call_command(
'import_memory',
get_test_file('memory.json')
)
memory = TranslationMemory()
self.assertEqual(memory.doc_count(), 1)
示例5: test_import_invalid_command
def test_import_invalid_command(self):
with self.assertRaises(CommandError):
call_command(
'import_memory',
get_test_file('cs.po')
)
memory = TranslationMemory()
self.assertEqual(memory.doc_count(), 0)
示例6: test_import_empty_json_command
def test_import_empty_json_command(self):
with self.assertRaises(CommandError):
call_command(
'import_memory',
get_test_file('memory-empty.json')
)
memory = TranslationMemory()
self.assertEqual(memory.doc_count(), 0)
示例7: test_extra_file
def test_extra_file(self):
"""
Test extra commit file handling.
"""
subproject = self.create_subproject()
subproject.pre_commit_script = get_test_file("../../../../examples/hook-generate-mo")
appsettings.PRE_COMMIT_SCRIPT_CHOICES.append((subproject.pre_commit_script, "hook-generate-mo"))
subproject.extra_commit_file = "po/%(language)s.mo"
subproject.save()
subproject.full_clean()
translation = subproject.translation_set.get(language_code="cs")
# change backend file
with open(translation.get_filename(), "a") as handle:
handle.write(" ")
# Test committing
translation.git_commit(None, "TEST <[email protected]>", timezone.now(), force_commit=True)
示例8: test_ssh_add
def test_ssh_add(self):
self.assertEqual(check_data_writable(), [])
try:
oldpath = os.environ['PATH']
os.environ['PATH'] = ':'.join(
(get_test_file(''), os.environ['PATH'])
)
# Verify there is button for adding
response = self.client.get(reverse('admin:ssh'))
self.assertContains(response, 'Add host key')
# Add the key
response = self.client.post(
reverse('admin:ssh'),
{'action': 'add-host', 'host': 'github.com'}
)
self.assertContains(response, 'Added host key for github.com')
finally:
os.environ['PATH'] = oldpath
# Check the file contains it
hostsfile = os.path.join(settings.DATA_DIR, 'ssh', 'known_hosts')
with open(hostsfile) as handle:
self.assertIn('github.com', handle.read())
示例9: get_test_file
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
#
from django.core.files import File
from django.urls import reverse
from rest_framework.test import APITestCase
from weblate.auth.models import User, Group
from weblate.screenshots.models import Screenshot
from weblate.trans.models import Project, Change, Unit, Source
from weblate.trans.tests.utils import RepoTestMixin, get_test_file
TEST_PO = get_test_file('cs.po')
TEST_SCREENSHOT = get_test_file('screenshot.png')
class APIBaseTest(APITestCase, RepoTestMixin):
def setUp(self):
self.clone_test_repos()
self.component = self.create_component()
self.translation_kwargs = {
'language__code': 'cs',
'component__slug': 'test',
'component__project__slug': 'test'
}
self.component_kwargs = {
'slug': 'test',
'project__slug': 'test'
示例10: import
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
'''
File format specific behavior.
'''
import tempfile
from unittest import TestCase
from weblate.trans.formats import (
AutoFormat, PoFormat, AndroidFormat, PropertiesFormat,
JSONFormat, RESXFormat,
FILE_FORMATS,
)
from weblate.trans.tests.utils import get_test_file
TEST_PO = get_test_file('cs.po')
TEST_JSON = get_test_file('cs.json')
TEST_PROPERTIES = get_test_file('swing.properties')
TEST_ANDROID = get_test_file('strings.xml')
TEST_POT = get_test_file('hello.pot')
TEST_RESX = get_test_file('cs.resx')
class AutoFormatTest(TestCase):
FORMAT = AutoFormat
FILE = TEST_PO
BASE = TEST_POT
MIME = 'text/x-gettext-catalog'
EXT = 'po'
COUNT = 5
MATCH = 'msgid_plural'
示例11: get_test_file
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
"""
Tests for dictionary manipulations.
"""
from __future__ import unicode_literals
from django.core.urlresolvers import reverse
from weblate.trans.tests.test_views import ViewTestCase
from weblate.trans.models import Dictionary
from weblate.trans.tests.utils import get_test_file
TEST_TBX = get_test_file('terms.tbx')
TEST_CSV = get_test_file('terms.csv')
TEST_CSV_HEADER = get_test_file('terms-header.csv')
TEST_PO = get_test_file('terms.po')
class DictionaryTest(ViewTestCase):
'''
Testing of dictionary manipulations.
'''
def get_url(self, url):
return reverse(url, kwargs={
'lang': 'cs',
'project': self.subproject.project.slug,
})
示例12: get_test_file
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
"""
Tests for import and export.
"""
from weblate.trans.tests.test_views import ViewTestCase
from django.core.urlresolvers import reverse
from weblate.trans.tests.utils import get_test_file
TEST_PO = get_test_file("cs.po")
TEST_CSV = get_test_file("cs.csv")
TEST_PO_BOM = get_test_file("cs-bom.po")
TEST_FUZZY_PO = get_test_file("cs-fuzzy.po")
TEST_MO = get_test_file("cs.mo")
TEST_ANDROID = get_test_file("strings-cs.xml")
TRANSLATION_OURS = u"Nazdar světe!\n"
TRANSLATION_PO = u"Ahoj světe!\n"
class ImportBaseTest(ViewTestCase):
"""
Base test of file imports.
"""
示例13: get_test_file
from django.core.management import call_command
from django.core.management.base import CommandError, SystemCheckError
from django.test import SimpleTestCase
from six import StringIO
from weblate.accounts.models import Profile
from weblate.runner import main
from weblate.trans.models import Component, Source, Suggestion, Translation
from weblate.trans.search import Fulltext
from weblate.trans.tests.test_models import RepoTestCase
from weblate.trans.tests.test_views import ViewTestCase
from weblate.trans.tests.utils import create_test_user, get_test_file
from weblate.vcs.mercurial import HgRepository
TEST_PO = get_test_file('cs.po')
TEST_COMPONENTS = get_test_file('components.json')
TEST_COMPONENTS_INVALID = get_test_file('components-invalid.json')
class RunnerTest(SimpleTestCase):
def test_help(self):
restore = sys.stdout
try:
sys.stdout = StringIO()
main(['help'])
self.assertIn('list_versions', sys.stdout.getvalue())
finally:
sys.stdout = restore
示例14: import
from django.utils.encoding import force_text
import six
from translate.storage.po import pofile
from weblate.lang.models import Language
from weblate.trans.formats import (
AutoFormat, PoFormat, AndroidFormat, PropertiesFormat,
JSONFormat, RESXFormat, PhpFormat, XliffFormat, TSFormat,
FILE_FORMATS, detect_filename,
)
from weblate.trans.tests.utils import get_test_file
TEST_PO = get_test_file('cs.po')
TEST_JSON = get_test_file('cs.json')
TEST_PHP = get_test_file('cs.php')
TEST_PROPERTIES = get_test_file('swing.properties')
TEST_ANDROID = get_test_file('strings.xml')
TEST_XLIFF = get_test_file('cs.xliff')
TEST_POT = get_test_file('hello.pot')
TEST_POT_UNICODE = get_test_file('unicode.pot')
TEST_RESX = get_test_file('cs.resx')
TEST_TS = get_test_file('cs.ts')
class AutoLoadTest(TestCase):
def single_test(self, filename, fileclass):
with open(filename, 'rb') as handle:
store = AutoFormat.parse(handle)
示例15: get_test_file
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
"""
Tests for import and export.
"""
from weblate.trans.tests.test_views import ViewTestCase
from django.core.urlresolvers import reverse
from weblate.trans.tests.utils import get_test_file
TEST_PO = get_test_file('cs.po')
TEST_MO = get_test_file('cs.mo')
TEST_ANDROID = get_test_file('strings-cs.xml')
TRANSLATION_OURS = u'Nazdar světe!\n'
TRANSLATION_PO = u'Ahoj světe!\n'
class ImportTest(ViewTestCase):
'''
Testing of file imports.
'''
test_file = TEST_PO
def setUp(self):
super(ImportTest, self).setUp()