Skip to content

Commit 5147ca1

Browse files
committed
0.0.3
1 parent fa735e3 commit 5147ca1

File tree

6 files changed

+47
-7
lines changed

6 files changed

+47
-7
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<a href="https://github.com/CrazyProger1/Translatable-Enums/blob/master/LICENSE"><img alt="GitHub" src="https://img.shields.io/github/license/CrazyProger1/Translatable-Enums"></a>
99
<a href="https://github.com/CrazyProger1/Translatable-Enums/releases/latest"><img alt="GitHub release (latest by date)" src="https://img.shields.io/github/v/release/CrazyProger1/Translatable-Enums"></a>
1010
<a href="https://pypi.org/project/translatable-enums/"><img alt="PyPI - Downloads" src="https://img.shields.io/pypi/dm/translatable-enums"></a>
11-
<img src="https://img.shields.io/badge/coverage-98%25-brightgreen" alt="Coverage"/>
11+
<img src="https://img.shields.io/badge/coverage-99%25-brightgreen" alt="Coverage"/>
1212
</p>
1313

1414
Translatable-Enums is an i18n tool which uses built-in Enums as a convenient way to store translation keys.
@@ -89,7 +89,7 @@ msgstr ""
8989

9090
## Status
9191

92-
``0.0.2`` - RELEASED
92+
``0.0.3`` - RELEASED
9393

9494
## Licence
9595

docs/CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,8 @@
77

88
- v0.0.2
99
- Added one-field translation (field.language)
10+
11+
12+
- v0.0.3
13+
- Expanded supported range of Python versions(3.10+)
14+
- Added more tests. Improved coverage percentage (to 99%)

i18n/settings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
APP = 'Translatable-Enums'
22
DESCRIPTION = ('Translatable-Enums is a i18n tool which uses built-in Enums '
33
'as an convenient way to store translation keys.')
4-
VERSION = '0.0.2'
4+
VERSION = '0.0.3'
55
AUTHOR = 'crazyproger1'

i18n/utils/potfile/types.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
from typing import Literal
1+
from typing import Literal, NewType
22

3-
type TextFileMode = Literal['r', 'w', 'a']
3+
TextFileMode = NewType('TextFileMode', Literal['r', 'w', 'a'])

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "translatable-enums"
3-
version = "0.0.2"
3+
version = "0.0.3"
44
description = "Translatable-Enums is a i18n tool which uses built-in Enums as an convenient way to store translation keys."
55
authors = ["CrazyProger1 <crazyproger1@gmail.com>"]
66
license = "MIT"
@@ -13,7 +13,7 @@ repository = "https://github.com/CrazyProger1/Translatable-Enums"
1313
documentation = "https://github.com/CrazyProger1/Translatable-Enums"
1414

1515
[tool.poetry.dependencies]
16-
python = "^3.12"
16+
python = "^3.10"
1717

1818

1919
[tool.poetry.group.dev.dependencies]

tests/utils/test_potfile.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import pytest
2+
import re
23

34
from i18n.utils.potfile import POTFile
45

@@ -17,6 +18,11 @@ def keys():
1718
}
1819

1920

21+
@pytest.fixture
22+
def template():
23+
return 'Template'
24+
25+
2026
@pytest.fixture
2127
def create_potfile(file, keys):
2228
with open(file=file, mode='w') as f:
@@ -44,3 +50,32 @@ def test_add_keys(file, keys):
4450

4551
assert len(keys) == 0
4652

53+
54+
def test_template(file, template):
55+
with POTFile(file, mode='w', template=template):
56+
pass
57+
58+
with open(file, mode='r') as potfile:
59+
assert potfile.read().strip() == template
60+
61+
62+
def test_duplicate_keys(file, keys):
63+
keys_with_duplicates = list(keys)
64+
keys_with_duplicates.append(keys.pop())
65+
66+
with POTFile(file, 'w') as potfile:
67+
with pytest.raises(KeyError):
68+
for key in keys_with_duplicates:
69+
potfile.write(key=key, check_key=True)
70+
71+
72+
def test_comment_adding(file):
73+
comment = 'test_comment'
74+
with POTFile(file, 'w') as potfile:
75+
potfile.write(
76+
key='test',
77+
comment=comment
78+
)
79+
80+
with open(file, mode='r') as potfile:
81+
assert len(re.findall(r'#\s+' + comment, potfile.read())) == 1

0 commit comments

Comments
 (0)