Debian Codegraph @

tests/messages/frontend/test_compile.py

raw
1 #
2 # Copyright (C) 2007-2011 Edgewall Software, 2013-2025 the Babel team
3 # All rights reserved.
4 #
5 # This software is licensed as described in the file LICENSE, which
6 # you should have received as part of this distribution. The terms
7 # are also available at https://github.com/python-babel/babel/blob/master/LICENSE.
8 #
9 # This software consists of voluntary contributions made by many
10 # individuals. For the exact contribution history, see the revision
11 # history and logs, available at https://github.com/python-babel/babel/commits/master/.
12
13 from __future__ import annotations
14
15 import pytest
16
17 from babel.messages import frontend
18 from babel.messages.frontend import OptionError
19 from tests.messages.consts import TEST_PROJECT_DISTRIBUTION_DATA, data_dir
20 from tests.messages.utils import Distribution
21
22
23 @pytest.fixture
24 def compile_catalog_cmd(monkeypatch):
25 monkeypatch.chdir(data_dir)
26 dist = Distribution(TEST_PROJECT_DISTRIBUTION_DATA)
27 cmd = frontend.CompileCatalog(dist)
28 cmd.initialize_options()
29 return cmd
30
31
32 def test_no_directory_or_output_file_specified(compile_catalog_cmd):
33 compile_catalog_cmd.locale = 'en_US'
34 compile_catalog_cmd.input_file = 'dummy'
35 with pytest.raises(OptionError):
36 compile_catalog_cmd.finalize_options()
37
38
39 def test_no_directory_or_input_file_specified(compile_catalog_cmd):
40 compile_catalog_cmd.locale = 'en_US'
41 compile_catalog_cmd.output_file = 'dummy'
42 with pytest.raises(OptionError):
43 compile_catalog_cmd.finalize_options()