[issue22478] tests for urllib2net are in bad shapes

2014-09-24 Thread karl

New submission from karl:

→ ./python.exe -V
Python 3.4.2rc1+

→ hg tip
changeset:   92532:6dcc96fa3970
tag: tip
parent:  92530:ad45c2707006
parent:  92531:8eb4eec8626c
user:Benjamin Peterson benja...@python.org
date:Mon Sep 22 22:44:21 2014 -0400
summary: merge 3.4 (#22459)


When working on issue #5550, I realized that some tests are currently failing.

Here the log of running:
→ ./python.exe -m unittest -v Lib/test/test_urllib2net.py 


test_close (Lib.test.test_urllib2net.CloseSocketTest) ... ok
test_custom_headers (Lib.test.test_urllib2net.OtherNetworkTests) ... FAIL
test_file (Lib.test.test_urllib2net.OtherNetworkTests) ... test_ftp 
(Lib.test.test_urllib2net.OtherNetworkTests) ... skipped Resource 
'ftp://gatekeeper.research.compaq.com/pub/DEC/SRC/research-reports/00README-Legal-Rules-Regs'
 is not available
test_redirect_url_withfrag (Lib.test.test_urllib2net.OtherNetworkTests) ... ok
test_sites_no_connection_close (Lib.test.test_urllib2net.OtherNetworkTests) ... 
ok
test_urlwithfrag (Lib.test.test_urllib2net.OtherNetworkTests) ... ok
test_ftp_basic (Lib.test.test_urllib2net.TimeoutTest) ... ok
test_ftp_default_timeout (Lib.test.test_urllib2net.TimeoutTest) ... ok
test_ftp_no_timeout (Lib.test.test_urllib2net.TimeoutTest) ... ok
test_ftp_timeout (Lib.test.test_urllib2net.TimeoutTest) ... ok
test_http_basic (Lib.test.test_urllib2net.TimeoutTest) ... ok
test_http_default_timeout (Lib.test.test_urllib2net.TimeoutTest) ... ok
test_http_no_timeout (Lib.test.test_urllib2net.TimeoutTest) ... ok
test_http_timeout (Lib.test.test_urllib2net.TimeoutTest) ... ok

==
ERROR: test_file (Lib.test.test_urllib2net.OtherNetworkTests) 
(url='file:/Users/karl/code/cpython/%40test_61795_tmp')
--
Traceback (most recent call last):
  File /Users/karl/code/cpython/Lib/test/test_urllib2net.py, line 243, in 
_test_urls
f = urlopen(url, req, TIMEOUT)
  File /Users/karl/code/cpython/Lib/test/test_urllib2net.py, line 33, in 
wrapped
return _retry_thrice(func, exc, *args, **kwargs)
  File /Users/karl/code/cpython/Lib/test/test_urllib2net.py, line 23, in 
_retry_thrice
return func(*args, **kwargs)
  File /Users/karl/code/cpython/Lib/urllib/request.py, line 447, in open
req = Request(fullurl, data)
  File /Users/karl/code/cpython/Lib/urllib/request.py, line 267, in __init__
origin_req_host = request_host(self)
  File /Users/karl/code/cpython/Lib/urllib/request.py, line 250, in 
request_host
host = _cut_port_re.sub(, host, 1)
TypeError: expected string or buffer

==
ERROR: test_file (Lib.test.test_urllib2net.OtherNetworkTests) 
(url=('file:///nonsensename/etc/passwd', None, class 'urllib.error.URLError'))
--
Traceback (most recent call last):
  File /Users/karl/code/cpython/Lib/test/test_urllib2net.py, line 243, in 
_test_urls
f = urlopen(url, req, TIMEOUT)
  File /Users/karl/code/cpython/Lib/test/test_urllib2net.py, line 33, in 
wrapped
return _retry_thrice(func, exc, *args, **kwargs)
  File /Users/karl/code/cpython/Lib/test/test_urllib2net.py, line 23, in 
_retry_thrice
return func(*args, **kwargs)
  File /Users/karl/code/cpython/Lib/urllib/request.py, line 447, in open
req = Request(fullurl, data)
  File /Users/karl/code/cpython/Lib/urllib/request.py, line 267, in __init__
origin_req_host = request_host(self)
  File /Users/karl/code/cpython/Lib/urllib/request.py, line 250, in 
request_host
host = _cut_port_re.sub(, host, 1)
TypeError: expected string or buffer

==
FAIL: test_custom_headers (Lib.test.test_urllib2net.OtherNetworkTests)
--
Traceback (most recent call last):
  File /Users/karl/code/cpython/Lib/test/test_urllib2net.py, line 186, in 
test_custom_headers
self.assertEqual(request.get_header('User-agent'), 'Test-Agent')
AssertionError: 'Python-urllib/3.4' != 'Test-Agent'
- Python-urllib/3.4
+ Test-Agent


--
Ran 16 tests in 124.879s

FAILED (failures=1, errors=2, skipped=1)

--
components: Tests
messages: 227417
nosy: karlcow
priority: normal
severity: normal
status: open
title: tests for urllib2net are in bad shapes
versions: Python 3.5

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue22478
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue22478] tests for urllib2net are in bad shapes

2014-09-24 Thread karl

karl added the comment:

ok let's see

→ ./python.exe -m unittest -v 
Lib.test.test_urllib2net.OtherNetworkTests.test_custom_headers
test_custom_headers (Lib.test.test_urllib2net.OtherNetworkTests) ... FAIL

==
FAIL: test_custom_headers (Lib.test.test_urllib2net.OtherNetworkTests)
--
Traceback (most recent call last):
  File /Users/karl/code/cpython/Lib/test/test_urllib2net.py, line 186, in 
test_custom_headers
self.assertEqual(request.get_header('User-agent'), 'Test-Agent')
AssertionError: 'Python-urllib/3.4' != 'Test-Agent'
- Python-urllib/3.4
+ Test-Agent


--
Ran 1 test in 0.551s

FAILED (failures=1)


→ ./python.exe
Python 3.4.2rc1+ (3.4:8eb4eec8626c+, Sep 23 2014, 21:53:11) 
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.51)] on darwin
Type help, copyright, credits or license for more information.
 import urllib.request
 url = 'http://127.0.0.1/'
 opener = urllib.request.build_opener()
 request = urllib.request.Request(url)
 request.header_items()
[]
 request.headers
{}
 request.add_header('User-Agent', 'Test-Agent')
 request.headers
{'User-agent': 'Test-Agent'}
 request.header_items()
[('User-agent', 'Test-Agent')]
 opener.open(request)
http.client.HTTPResponse object at 0x10c0aedc0
 request.get_header('User-agent'), 'Test-Agent'
('Test-Agent', 'Test-Agent')
 request.header_items()
[('User-agent', 'Test-Agent'), ('Host', '127.0.0.1')]
 request.headers
{'User-agent': 'Test-Agent'}


OK so far so good.
And my server recorded 
127.0.0.1 - - [24/Sep/2014:17:07:41 +0900] GET / HTTP/1.1 200 9897 - 
Test-Agent


Let's do it the way, the test has been designed.

→ ./python.exe
Python 3.4.2rc1+ (3.4:8eb4eec8626c+, Sep 23 2014, 21:53:11) 
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.51)] on darwin
Type help, copyright, credits or license for more information.
 import urllib.request
 url = 'http://127.0.0.1/'
 opener = urllib.request.build_opener()
 request = urllib.request.Request(url)
 request.header_items()
[]
 opener.open(request)
http.client.HTTPResponse object at 0x10e05aa80
 request.header_items()
[('User-agent', 'Python-urllib/3.4'), ('Host', '127.0.0.1')]
 request.has_header('User-agent')
True
 request.add_header('User-Agent', 'Test-Agent')
 opener.open(request)
http.client.HTTPResponse object at 0x10e05ab50
 request.get_header('User-agent'), 'Test-Agent'
('Python-urllib/3.4', 'Test-Agent')
 request.add_header('Foo', 'bar')
 request.header_items()
[('User-agent', 'Test-Agent'), ('Host', '127.0.0.1'), ('Foo', 'bar')]
 opener.open(request)
http.client.HTTPResponse object at 0x10e05ad58
 request.header_items()
[('User-agent', 'Test-Agent'), ('Host', '127.0.0.1'), ('Foo', 'bar')]
 request.get_header('User-agent'), 'Test-Agent'
('Python-urllib/3.4', 'Test-Agent')
 request.headers
{'User-agent': 'Test-Agent', 'Foo': 'bar'}


And the server recorded.

127.0.0.1 - - [24/Sep/2014:17:12:52 +0900] GET / HTTP/1.1 200 9897 - 
Python-urllib/3.4
127.0.0.1 - - [24/Sep/2014:17:12:52 +0900] GET / HTTP/1.1 200 9897 - 
Python-urllib/3.4
127.0.0.1 - - [24/Sep/2014:17:14:15 +0900] GET / HTTP/1.1 200 9897 - 
Python-urllib/3.4

So it seems that User-Agent is immutable once it has been set the first time. 
Not in  the same dictionary.


 request.unredirected_hdrs
{'User-agent': 'Python-urllib/3.4', 'Host': '127.0.0.1'}

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue22478
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue22478] tests for urllib2net are in bad shapes

2014-09-24 Thread karl

karl added the comment:

Ah! the User-Agent (or anything which is in unredirected_hdrs) will not be 
updated if it has already been set once. 
https://hg.python.org/cpython/file/064f6baeb6bd/Lib/urllib/request.py#l1154


 headers = dict(request.unredirected_hdrs)
 headers
{'User-agent': 'Python-urllib/3.4', 'Host': '127.0.0.1'}
 request.headers
{'User-agent': 'Test-Agent', 'Foo': 'cool'}
 headers.update(dict((k, v) for k, v in request.headers.items() if k not in 
 headers))
 headers
{'User-agent': 'Python-urllib/3.4', 'Host': '127.0.0.1', 'Foo': 'cool'}

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue22478
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue22478] tests for urllib2net are in bad shapes

2014-09-24 Thread Ned Deily

Changes by Ned Deily n...@acm.org:


--
nosy: +orsenthil

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue22478
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue22478] tests for urllib2net are in bad shapes

2014-09-24 Thread Senthil Kumaran

Senthil Kumaran added the comment:

I suspect that you have your interpreters confused. (For e.g, I see 3.4 run 
against the trunk and the error messages are leading me to believe that 2.7 
version in run on 3 code).

Or your local copy is not in right shape.

I tested it on 3.4 and cpython default and everything was OK.

[localhost 3.4]$ ./python.exe -m unittest -v Lib/test/test_urllib2net.py
...
Ran 15 tests in 36.672s

OK
[localhost 3.4]$ hg log -r 3.4
changeset:   92551:bce1594023f9
branch:  3.4
parent:  92548:381d6362c7bc
parent:  92546:ff2cb4dc36e7
user:Serhiy Storchaka storch...@gmail.com
date:Tue Sep 23 23:23:41 2014 +0300
description:
Merge heads

[localhost cpython]$ ./python.exe -m unittest -v Lib/test/test_urllib2net.py
...
Ran 15 tests in 32.779s

OK
[localhost cpython]$ hg log -r tip
changeset:   92555:064f6baeb6bd
tag: tip
user:Georg Brandl ge...@python.org
date:Wed Sep 24 09:08:12 2014 +0200
files:   Python/importlib.h
description:
Update importlib.h frozen bytecode (changed due to commit c0ca9d32aed4).

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue22478
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue22478] tests for urllib2net are in bad shapes

2014-09-24 Thread Senthil Kumaran

Senthil Kumaran added the comment:

The buildbots are not showing this error too. I suggest you reset your local 
copy with the pristine one from remote, do a make distclean; ./configure; make 
and then run the tests.

--
assignee:  - orsenthil
resolution:  - works for me
stage:  - resolved
status: open - closed
type:  - behavior

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue22478
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com