Merge pull request #1213 from nicoddemus/pastebin-py3
merge Pastebin py3 support also closes #1202 and fixes #1198
This commit is contained in:
commit
7232b45f25
|
@ -6,6 +6,9 @@
|
||||||
module. Thanks Mikhail Chernykh for the report and Bruno Oliveira for the
|
module. Thanks Mikhail Chernykh for the report and Bruno Oliveira for the
|
||||||
PR.
|
PR.
|
||||||
|
|
||||||
|
- fix #1198: ``--pastebin`` option now works on Python 3. Thanks
|
||||||
|
Mehdy Khoshnoody for the PR.
|
||||||
|
|
||||||
- fix #1204: another error when collecting with a nasty __getattr__().
|
- fix #1204: another error when collecting with a nasty __getattr__().
|
||||||
Thanks Florian Bruhin for the PR.
|
Thanks Florian Bruhin for the PR.
|
||||||
|
|
||||||
|
|
|
@ -61,8 +61,8 @@ def create_new_paste(contents):
|
||||||
'expiry': '1week',
|
'expiry': '1week',
|
||||||
}
|
}
|
||||||
url = 'https://bpaste.net'
|
url = 'https://bpaste.net'
|
||||||
response = urlopen(url, data=urlencode(params)).read()
|
response = urlopen(url, data=urlencode(params).encode()).read()
|
||||||
m = re.search(r'href="/raw/(\w+)"', response)
|
m = re.search(r'href="/raw/(\w+)"', response.decode())
|
||||||
if m:
|
if m:
|
||||||
return '%s/show/%s' % (url, m.group(1))
|
return '%s/show/%s' % (url, m.group(1))
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import sys
|
import sys
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
class TestPasting:
|
class TestPasteCapture:
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def pastebinlist(self, monkeypatch, request):
|
def pastebinlist(self, monkeypatch, request):
|
||||||
|
@ -62,7 +62,7 @@ class TestPaste:
|
||||||
class DummyFile:
|
class DummyFile:
|
||||||
def read(self):
|
def read(self):
|
||||||
# part of html of a normal response
|
# part of html of a normal response
|
||||||
return 'View <a href="/raw/3c0c6750bd">raw</a>.'
|
return b'View <a href="/raw/3c0c6750bd">raw</a>.'
|
||||||
return DummyFile()
|
return DummyFile()
|
||||||
|
|
||||||
if sys.version_info < (3, 0):
|
if sys.version_info < (3, 0):
|
||||||
|
@ -78,10 +78,11 @@ class TestPaste:
|
||||||
assert result == 'https://bpaste.net/show/3c0c6750bd'
|
assert result == 'https://bpaste.net/show/3c0c6750bd'
|
||||||
assert len(mocked_urlopen) == 1
|
assert len(mocked_urlopen) == 1
|
||||||
url, data = mocked_urlopen[0]
|
url, data = mocked_urlopen[0]
|
||||||
|
assert type(data) is bytes
|
||||||
lexer = 'python3' if sys.version_info[0] == 3 else 'python'
|
lexer = 'python3' if sys.version_info[0] == 3 else 'python'
|
||||||
assert url == 'https://bpaste.net'
|
assert url == 'https://bpaste.net'
|
||||||
assert 'lexer=%s' % lexer in data
|
assert 'lexer=%s' % lexer in data.decode()
|
||||||
assert 'code=full-paste-contents' in data
|
assert 'code=full-paste-contents' in data.decode()
|
||||||
assert 'expiry=1week' in data
|
assert 'expiry=1week' in data.decode()
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue