-
Notifications
You must be signed in to change notification settings - Fork 46
Change the test cases to pytest. #47
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
8286ee7
0f52666
696a9c2
b3743b5
24378a8
6ca161f
d65e5bd
8954134
4f0f027
2ca53a5
a3c6904
0bea323
952c6df
f70d6c0
d2da05b
957605a
91bfb6c
dca293b
94a886a
c8b9ffc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| name: Auto Assign | ||
|
|
||
| on: | ||
| issues: | ||
| types: [opened, reopened] | ||
| pull_request_target: | ||
| types: [opened, reopened] | ||
|
|
||
| permissions: | ||
| issues: write | ||
| pull-requests: write | ||
|
|
||
| jobs: | ||
| assign-author: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: toshimaru/auto-author-assign@v3.0.1 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| name: Top issues action. | ||
| on: | ||
| schedule: | ||
| - cron: "0 0 */1 * *" | ||
|
|
||
| jobs: | ||
| check: | ||
| name: Check for open issues | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| issues: read | ||
| contents: read | ||
| outputs: | ||
| has_open_issues: ${{ steps.check.outputs.result }} | ||
| steps: | ||
| - id: check | ||
| name: Check open issues | ||
| uses: actions/github-script@v6 | ||
| with: | ||
| script: | | ||
| const owner = context.repo.owner; | ||
| const repo = context.repo.repo; | ||
| const issues = await github.rest.issues.listForRepo({ owner, repo, state: 'open', per_page: 5 }); | ||
| // Exclude pull requests — only count real issues | ||
| const hasIssue = issues.data.some(i => !i.pull_request); | ||
| return hasIssue ? 'true' : 'false'; | ||
|
|
||
| ShowAndLabelTopIssues: | ||
| name: Display and label top issues. | ||
| needs: check | ||
| if: needs.check.outputs.has_open_issues == 'true' | ||
| permissions: | ||
| contents: read | ||
| issues: write | ||
| pull-requests: write | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Run top issues action | ||
| uses: rickstaa/top-issues-action@v1 | ||
| env: | ||
| github_token: ${{ secrets.GITHUB_TOKEN }} | ||
| with: | ||
| label: true | ||
| dashboard: true | ||
| dashboard_show_total_reactions: true | ||
| top_issues: true | ||
| top_bugs: true | ||
| top_features: true | ||
| top_pull_requests: true |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,14 +1,18 @@ | ||
| language: python | ||
| python: | ||
| - "2.7" | ||
| - "3.6" | ||
| - "3.7" | ||
| - "3.8" | ||
| - "3.9" | ||
| - "3.10" | ||
| - "3.11" | ||
| - "3.12" | ||
| - "3.13" | ||
| # command to install dependencies | ||
| install: "pip install -r requirements.txt" | ||
| install: | ||
| - pip install -r requirements.txt | ||
| - pip install -e . | ||
| # command to run tests | ||
| script: | ||
| - python setup.py test | ||
| - coverage run --source=i18n setup.py test | ||
| - pytest --maxfail=1 --disable-warnings --tb=short | ||
| - coverage run -m pytest | ||
| after_success: | ||
| - coveralls | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -65,12 +65,14 @@ def get_namespace_from_filepath(filename): | |
| ) | ||
| if "{namespace}" in config.get("filename_format"): | ||
| try: | ||
| format_parts = config.get("filename_format").split(".") | ||
| namespace_index = format_parts.index("{namespace}") | ||
| splitted_filename = os.path.basename(filename).split(".") | ||
| if namespace_index >= len(splitted_filename): | ||
| raise I18nFileLoadError("incorrect file format.") | ||
| if namespace: | ||
| namespace += config.get("namespace_delimiter") | ||
| namespace += splitted_filename[ | ||
| config.get("filename_format").index("{namespace}") | ||
| ] | ||
| namespace += splitted_filename[namespace_index] | ||
| except ValueError: | ||
| raise I18nFileLoadError("incorrect file format.") | ||
| return namespace | ||
|
|
@@ -85,13 +87,20 @@ def load_translation_file(filename, base_directory, locale=config.get("locale")) | |
|
|
||
|
|
||
| def load_translation_dic(dic, namespace, locale): | ||
| if namespace: | ||
| namespace += config.get("namespace_delimiter") | ||
| if isinstance(dic, dict) and len(dic) == 1 and locale in dic: | ||
| dic = dic[locale] | ||
|
Comment on lines
+90
to
+91
|
||
| delimiter = config.get("namespace_delimiter") | ||
|
|
||
| def join_ns(ns, k): | ||
| if not ns: | ||
| return k | ||
| return ns + delimiter + k | ||
|
|
||
| for key, value in dic.items(): | ||
| if isinstance(value, dict) and len(set(PLURALS).intersection(value)) < 2: | ||
| load_translation_dic(value, namespace + key, locale) | ||
| load_translation_dic(value, join_ns(namespace, key), locale) | ||
| else: | ||
| translations.add(namespace + key, value, locale) | ||
| translations.add(join_ns(namespace, key), value, locale) | ||
|
|
||
|
|
||
| def load_directory(directory, locale=config.get("locale")): | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.