Eine aufbereitete Darstellung der Quelle

 
     
 
 
Anforderungen  |   Konzepte  |   Entwurf  |   Entwicklung  |   Qualitätssicherung  |   Lebenszyklus  |   Steuerung
 
 
 
 

Benutzer

Quelle  test_l10n_locales.py   Sprache: Python

 

import os
import shutil
import unittest
from unittest import mock

import mozunit
from mozharness.base import script
from mozharness.mozilla.l10n import locales

ALL_LOCALES = ["ar", "be", "de", "es-ES"]

MH_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))


def cleanup():
    if os.path.exists("test_logs"):
        shutil.rmtree("test_logs", ignore_errors=True)


class LocalesTest(locales.LocalesMixin, script.BaseScript):
    def __init__(self, **kwargs):
        if "config" not in kwargs:
            kwargs["config"] = {"log_type": "simple", "log_level": "error"}
        if "initial_config_file" not in kwargs:
            kwargs["initial_config_file"] = "test/test.json"
        super().__init__(**kwargs)
        self.config = {}
        self.log_obj = None


@mock.patch.dict("os.environ", GECKO_PATH="gecko_src")
class TestLocalesMixin(unittest.TestCase):
    BASE_ABS_DIRS = {
        "abs_log_dir",
        "abs_work_dir",
        "base_work_dir",
        "abs_src_dir",
        "abs_locales_src_dir",
        "abs_l10n_dir",
        "abs_obj_dir",
        "abs_locales_dir",
    }

    def setUp(self):
        cleanup()

    def tearDown(self):
        cleanup()

    def test_query_locales_locales(self):
        l = LocalesTest()
        l.locales = ["a", "b", "c"]
        self.assertEqual(l.locales, l.query_locales())

    def test_query_locales_ignore_locales(self):
        l = LocalesTest()
        l.config["locales"] = ["a", "b", "c"]
        l.config["ignore_locales"] = ["a", "c"]
        self.assertEqual(["b"], l.query_locales())

    def test_query_locales_config(self):
        l = LocalesTest()
        l.config["locales"] = ["a", "b", "c"]
        self.assertEqual(l.config["locales"], l.query_locales())

    def test_query_locales_json(self):
        l = LocalesTest()
        l.config["locales_file"] = os.path.join(
            MH_DIR, "test/helper_files/locales.json"
        )
        l.config["base_work_dir"] = "."
        l.config["work_dir"] = "."
        l.config["locales_dir"] = "locales_dir"
        l.config["objdir"] = "objdir"
        locales = l.query_locales()
        locales.sort()
        self.assertEqual(ALL_LOCALES, locales)

    # Commenting out til we can hide the FATAL ?
    #    def test_query_locales_no_file(self):
    #        l = LocalesTest()
    #        l.config['base_work_dir'] = '.'
    #        l.config['work_dir'] = '.'
    #        try:
    #            l.query_locales()
    #        except SystemExit:
    #            pass # Good
    #        else:
    #            self.assertTrue(False, "query_locales with no file doesn't fatal()!")

    def test_parse_locales_file(self):
        l = LocalesTest()
        self.assertEqual(
            ALL_LOCALES,
            l.parse_locales_file(os.path.join(MH_DIR, "test/helper_files/locales.txt")),
        )

    def _get_query_abs_dirs_obj(self):
        l = LocalesTest()
        l.config["base_work_dir"] = "base_work_dir"
        l.config["work_dir"] = "work_dir"
        l.config["locales_dir"] = "locales_dir"
        l.config["objdir"] = "objdir"
        return l

    def test_query_abs_dirs_base(self):
        l = self._get_query_abs_dirs_obj()
        dirs = set(l.query_abs_dirs().keys())
        self.assertEqual(dirs, self.BASE_ABS_DIRS)

    def test_query_abs_dirs_base2(self):
        l = self._get_query_abs_dirs_obj()
        l.query_abs_dirs().keys()
        dirs = set(l.query_abs_dirs().keys())
        self.assertEqual(dirs, self.BASE_ABS_DIRS)


if __name__ == "__main__":
    mozunit.main()

Messung
CHZG
871009794

¤ Dauer der Verarbeitung: 0.0 Sekunden  (vorverarbeitet am  2026-11-08) ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

PVS Prover

Isabelle Prover


Cephes Mathematical Library

Vienna Development Method

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.






                                                                                                                                                                                                                                                                                                                                                                                                     


Neuigkeiten

Aktuelles
Motto des Tages

Open Source Software


Jenseits des Üblichen

Besucherstatistik

Besucherstatistik

Statistik
#Sources=1102655
#Domains=556605