You've already forked httpie-cli
mirror of
https://github.com/httpie/cli.git
synced 2026-06-20 11:32:56 +02:00
Finished pytest migration.
This commit is contained in:
+1
-3
@@ -5,15 +5,13 @@ import json
|
||||
import shutil
|
||||
import tempfile
|
||||
|
||||
# HACK: Prepend ../ to PYTHONPATH so that we can import httpie form there.
|
||||
TESTS_ROOT = os.path.abspath(os.path.dirname(__file__))
|
||||
sys.path.insert(0, os.path.realpath(os.path.join(TESTS_ROOT, '..')))
|
||||
from httpie import ExitStatus
|
||||
from httpie.models import Environment
|
||||
from httpie.core import main
|
||||
from httpie.compat import bytes, str
|
||||
|
||||
|
||||
TESTS_ROOT = os.path.abspath(os.path.dirname(__file__))
|
||||
HTTPBIN_URL = os.environ.get('HTTPBIN_URL',
|
||||
'http://httpbin.org').rstrip('/')
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ import os
|
||||
import time
|
||||
from unittest import TestCase
|
||||
|
||||
import pytest
|
||||
from requests.structures import CaseInsensitiveDict
|
||||
|
||||
from httpie.compat import urlopen
|
||||
@@ -32,22 +33,22 @@ class DownloadUtilsTest(TestCase):
|
||||
assert parse('bytes 100-199/*', 100) == 200
|
||||
|
||||
# missing
|
||||
self.assertRaises(ContentRangeError, parse, None, 100)
|
||||
pytest.raises(ContentRangeError, parse, None, 100)
|
||||
|
||||
# syntax error
|
||||
self.assertRaises(ContentRangeError, parse, 'beers 100-199/*', 100)
|
||||
pytest.raises(ContentRangeError, parse, 'beers 100-199/*', 100)
|
||||
|
||||
# unexpected range
|
||||
self.assertRaises(ContentRangeError, parse, 'bytes 100-199/*', 99)
|
||||
pytest.raises(ContentRangeError, parse, 'bytes 100-199/*', 99)
|
||||
|
||||
# invalid instance-length
|
||||
self.assertRaises(ContentRangeError, parse, 'bytes 100-199/199', 100)
|
||||
pytest.raises(ContentRangeError, parse, 'bytes 100-199/199', 100)
|
||||
|
||||
# invalid byte-range-resp-spec
|
||||
self.assertRaises(ContentRangeError, parse, 'bytes 100-99/199', 100)
|
||||
pytest.raises(ContentRangeError, parse, 'bytes 100-99/199', 100)
|
||||
|
||||
# invalid byte-range-resp-spec
|
||||
self.assertRaises(ContentRangeError, parse, 'bytes 100-100/*', 100)
|
||||
pytest.raises(ContentRangeError, parse, 'bytes 100-100/*', 100)
|
||||
|
||||
def test_Content_Disposition_parsing(self):
|
||||
parse = filename_from_content_disposition
|
||||
|
||||
@@ -17,9 +17,10 @@ class VerboseFlagTest(TestCase):
|
||||
def test_verbose_form(self):
|
||||
# https://github.com/jkbr/httpie/issues/53
|
||||
r = http('--verbose', '--form', 'POST', httpbin('/post'),
|
||||
'foo=bar', 'baz=bar')
|
||||
'A=B', 'C=D')
|
||||
assert HTTP_OK in r
|
||||
assert 'foo=bar&baz=bar' in r
|
||||
# Python 2.6 has no ordered dict, so we test for both orders here.
|
||||
assert 'A=B&C=D' in r or 'C=D&A=B', r
|
||||
|
||||
def test_verbose_json(self):
|
||||
r = http('--verbose', 'POST', httpbin('/post'), 'foo=bar', 'baz=bar')
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
import os
|
||||
from unittest import TestCase
|
||||
|
||||
import pytest
|
||||
|
||||
from httpie.input import ParseError
|
||||
from tests import TestEnvironment, http, httpbin, HTTP_OK
|
||||
from tests.fixtures import FILE_PATH_ARG, FILE_PATH, FILE_CONTENT
|
||||
@@ -8,7 +10,7 @@ from tests.fixtures import FILE_PATH_ARG, FILE_PATH, FILE_CONTENT
|
||||
|
||||
class MultipartFormDataFileUploadTest(TestCase):
|
||||
def test_non_existent_file_raises_parse_error(self):
|
||||
with self.assertRaises(ParseError):
|
||||
with pytest.raises(ParseError):
|
||||
http('--form', 'POST', httpbin('/post'), 'foo@/__does_not_exist__')
|
||||
|
||||
def test_upload_ok(self):
|
||||
|
||||
Reference in New Issue
Block a user