Skip to content

Commit 81548de

Browse files
author
Nidhal Baccouri
committed
fixed poetry install
1 parent 9bef22f commit 81548de

File tree

6 files changed

+19
-9
lines changed

6 files changed

+19
-9
lines changed

.github/workflows/production-tests.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ jobs:
2323
- name: Install poetry
2424
run: |
2525
which python
26-
curl -sSL https://install.python-poetry.org | python${{ matrix.python-version }} -
26+
which pipx
27+
pipx install poetry
2728
2829
- name: Install dependencies
2930
run: |

.github/workflows/release.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ jobs:
2929
- name: Install poetry
3030
run: |
3131
which python
32-
curl -sSL https://install.python-poetry.org | python3 -
32+
which pipx
33+
pipx install poetry
3334
3435
- name: View poetry version
3536
run: poetry --version

.github/workflows/test-release.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ jobs:
2121
- name: Install poetry
2222
run: |
2323
which python
24-
curl -sSL https://install.python-poetry.org | python3 -
24+
which pipx
25+
pipx install poetry
2526
2627
- name: View poetry version
2728
run: poetry --version

.github/workflows/test.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ jobs:
66
test:
77
strategy:
88
matrix:
9-
python-version: ["3.7"]
9+
python-version: [ "3.7", "3.8", "3.9" ]
1010
os: [ubuntu-latest] # we can add other os like macOS-latest
1111
runs-on: ${{ matrix.os }}
1212
steps:

deep_translator/microsoft.py

+8-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,11 @@
1111

1212
from deep_translator.base import BaseTranslator
1313
from deep_translator.constants import BASE_URLS, MSFT_ENV_VAR
14-
from deep_translator.exceptions import ApiKeyException, MicrosoftAPIerror
14+
from deep_translator.exceptions import (
15+
ApiKeyException,
16+
MicrosoftAPIerror,
17+
TranslationNotFound,
18+
)
1519
from deep_translator.validate import is_input_valid
1620

1721

@@ -100,6 +104,9 @@ def translate(self, text: str, **kwargs) -> str:
100104
exc_type, value, traceback = sys.exc_info()
101105
logging.warning(f"Returned error: {exc_type.__name__}")
102106

107+
if response is None:
108+
raise TranslationNotFound(text)
109+
103110
# Where Microsoft API responds with an api error, it returns a dict in response.json()
104111
if type(response.json()) is dict:
105112
error_message = response.json()["error"]

tests/test_microsoft_trans.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,10 @@ def json_func():
3636

3737

3838
def test_MicrosoftAPIerror():
39-
with pytest.raises(exceptions.MicrosoftAPIerror):
40-
MicrosoftTranslator(
41-
api_key="empty", source="de", target="en"
42-
).translate("text")
39+
with pytest.raises(exceptions.ApiKeyException):
40+
MicrosoftTranslator(api_key="", source="de", target="en").translate(
41+
"text"
42+
)
4343

4444

4545
# the remaining tests are actual requests to Microsoft API and use an api key

0 commit comments

Comments
 (0)