Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
D
docker-py
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
docker-py
Commits
89afee94
Kaydet (Commit)
89afee94
authored
Eyl 14, 2016
tarafından
Joffrey F
Kaydeden (comit)
GitHub
Eyl 14, 2016
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Sade Fark
Merge pull request #1213 from bfirsh/parse-json-errors
Parse JSON API errors
üst
ad350b95
dcd01f0f
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
23 additions
and
3 deletions
+23
-3
errors.py
docker/errors.py
+4
-1
container_test.py
tests/integration/container_test.py
+2
-2
errors_test.py
tests/integration/errors_test.py
+17
-0
No files found.
docker/errors.py
Dosyayı görüntüle @
89afee94
...
...
@@ -11,7 +11,10 @@ class APIError(requests.exceptions.HTTPError):
self
.
explanation
=
explanation
if
self
.
explanation
is
None
and
response
.
content
:
self
.
explanation
=
response
.
content
.
strip
()
try
:
self
.
explanation
=
response
.
json
()[
'message'
]
except
ValueError
:
self
.
explanation
=
response
.
content
.
strip
()
def
__str__
(
self
):
message
=
super
(
APIError
,
self
)
.
__str__
()
...
...
tests/integration/container_test.py
Dosyayı görüntüle @
89afee94
...
...
@@ -118,7 +118,7 @@ class CreateContainerTest(helpers.BaseTestCase):
self
.
client
.
wait
(
id
)
with
self
.
assertRaises
(
docker
.
errors
.
APIError
)
as
exc
:
self
.
client
.
remove_container
(
id
)
err
=
exc
.
exception
.
response
.
text
err
=
exc
.
exception
.
explanation
self
.
assertIn
(
'You cannot remove a running container'
,
err
)
...
...
@@ -289,7 +289,7 @@ class CreateContainerTest(helpers.BaseTestCase):
)
self
.
client
.
start
(
container
)
assert
six
.
b
(
expected_msg
)
in
excinfo
.
value
.
explanation
assert
excinfo
.
value
.
explanation
==
expected_msg
def
test_valid_no_log_driver_specified
(
self
):
log_config
=
docker
.
utils
.
LogConfig
(
...
...
tests/integration/errors_test.py
0 → 100644
Dosyayı görüntüle @
89afee94
from
docker.errors
import
APIError
from
..
import
helpers
class
ErrorsTest
(
helpers
.
BaseTestCase
):
def
test_api_error_parses_json
(
self
):
container
=
self
.
client
.
create_container
(
helpers
.
BUSYBOX
,
[
'sleep'
,
'10'
]
)
self
.
client
.
start
(
container
[
'Id'
])
with
self
.
assertRaises
(
APIError
)
as
cm
:
self
.
client
.
remove_container
(
container
[
'Id'
])
explanation
=
cm
.
exception
.
explanation
assert
'You cannot remove a running container'
in
explanation
assert
'{"message":'
not
in
explanation
self
.
client
.
remove_container
(
container
[
'Id'
],
force
=
True
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment