This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: failure in test_httpservers
Type: behavior Stage: patch review
Components: Library (Lib), Tests Versions: Python 3.1, Python 2.7
process
Status: closed Resolution:
Dependencies: Superseder:
Assigned To: tarek Nosy List: doerwalter, gerluijten, mark.dickinson, ned.deily, pitrou, tarek
Priority: high Keywords: patch

Created on 2009-01-15 00:13 by pitrou, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
issue4951.patch mark.dickinson, 2009-04-24 22:09
Messages (11)
msg79881 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2009-01-15 00:13
This one seems to pop up rather frequently on the buildbots:


======================================================================
FAIL: test_post (test.test_httpservers.CGIHTTPServerTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File
"E:\cygwin\home\db3l\buildarea\3.x.bolen-windows\build\lib\test\test_httpservers.py",
line 330, in test_post
    self.assertEquals(res.read(), b'1, python, 123456\n')
AssertionError: b'' != b'1, python, 123456\n'

----------------------------------------------------------------------
msg83632 - (view) Author: Ger Luijten (gerluijten) Date: 2009-03-15 13:47
Reported Issue 5494 Failure in test_httpservers on Linux with other
error message. Maybe there is a relation, maybe not.
Greetings, Ger
msg84786 - (view) Author: Ned Deily (ned.deily) * (Python committer) Date: 2009-03-31 14:27
Also seeing on OS X.  Without having looked at the code yet, I wonder if 
this might be related to Issue1711605.
msg86420 - (view) Author: Mark Dickinson (mark.dickinson) * (Python committer) Date: 2009-04-24 18:14
This looks like an interaction with test_distutils.  On OS X 10.5.6 I get:

Macintosh-4:py3k dickinsm$ ./python.exe Lib/test/regrtest.py test_distutils test_httpservers
test_distutils
test_httpservers
Traceback (most recent call last):
  File "/private/var/folders/nL/nLe5s1a2G807X4++Ih2+y++++TI/-Tmp-/tmpXvtrLE/cgi-bin/file2.py", line 2, in <module>
    import cgi
  File "/Users/dickinsm/svn/python/py3k/Lib/cgi.py", line 34, in <module>
    from operator import attrgetter
ImportError: No module named operator
test test_httpservers failed -- Traceback (most recent call last):
  File "/Users/dickinsm/svn/python/py3k/Lib/test/test_httpservers.py", line 370, in test_post
    self.assertEquals(res.read(), b'1, python, 123456\n')
AssertionError: b'' != b'1, python, 123456\n'

1 test OK.
1 test failed:
    test_httpservers

But if I run test_httpservers by itself all tests pass.

Adding Tarek to the nosy list, in case he knows anything that might help.
msg86422 - (view) Author: Mark Dickinson (mark.dickinson) * (Python committer) Date: 2009-04-24 18:18
Here's the verbose test output:

Macintosh-4:py3k dickinsm$ ./python.exe Lib/test/regrtest.py -v test_distutils test_httpservers
test_distutils
test_formats (distutils.tests.test_bdist.BuildTestCase) ... ok
test_simple_built (distutils.tests.test_bdist_dumb.BuildDumbTestCase) ... ok
test_no_optimize_flag (distutils.tests.test_bdist_rpm.BuildRpmTestCase) ... ok
test_quiet (distutils.tests.test_bdist_rpm.BuildRpmTestCase) ... ok
test_get_exe_bytes (distutils.tests.test_bdist_wininst.BuildWinInstTestCase) ... ok
test_build_ext (distutils.tests.test_build_ext.BuildExtTestCase) ... ok
test_optional_extension (distutils.tests.test_build_ext.BuildExtTestCase) ... ok
test_solaris_enable_shared (distutils.tests.test_build_ext.BuildExtTestCase) ... ok
test_user_site (distutils.tests.test_build_ext.BuildExtTestCase) ... ok
test_empty_package_dir (distutils.tests.test_build_py.BuildPyTestCase) ... ok
test_package_data (distutils.tests.test_build_py.BuildPyTestCase) ... ok
test_build (distutils.tests.test_build_scripts.BuildScriptsTestCase) ... ok
test_default_settings (distutils.tests.test_build_scripts.BuildScriptsTestCase) ... ok
test_version_int (distutils.tests.test_build_scripts.BuildScriptsTestCase) ... ok
test_check_all (distutils.tests.test_check.CheckTestCase) ... ok
test_check_document (distutils.tests.test_check.CheckTestCase) ... ok
test_check_metadata (distutils.tests.test_check.CheckTestCase) ... ok
test_check_restructuredtext (distutils.tests.test_check.CheckTestCase) ... ok
test_simple_run (distutils.tests.test_clean.cleanTestCase) ... ok
test_dump_options (distutils.tests.test_cmd.CommandTestCase) ... ok
test_ensure_dirname (distutils.tests.test_cmd.CommandTestCase) ... ok
test_ensure_filename (distutils.tests.test_cmd.CommandTestCase) ... ok
test_ensure_string (distutils.tests.test_cmd.CommandTestCase) ... ok
test_ensure_string_list (distutils.tests.test_cmd.CommandTestCase) ... ok
test_make_file (distutils.tests.test_cmd.CommandTestCase) ... ok
test_server_empty_registration (distutils.tests.test_config.PyPIRCCommandTestCase) ... ok
test_server_registration (distutils.tests.test_config.PyPIRCCommandTestCase) ... ok
test_clean (distutils.tests.test_config_cmd.ConfigTestCase) ... ok
test_dump_file (distutils.tests.test_config_cmd.ConfigTestCase) ... ok
test_finalize_options (distutils.tests.test_config_cmd.ConfigTestCase) ... ok
test_search_cpp (distutils.tests.test_config_cmd.ConfigTestCase) ... ok
test_run_setup_provides_file (distutils.tests.test_core.CoreTestCase) ... ok
test_run_setup_uses_current_dir (distutils.tests.test_core.CoreTestCase) ... ok
test_copy_tree_verbosity (distutils.tests.test_dir_util.DirUtilTestCase) ... ok
test_create_tree_verbosity (distutils.tests.test_dir_util.DirUtilTestCase) ... ok
test_mkpath_remove_tree_verbosity (distutils.tests.test_dir_util.DirUtilTestCase) ... ok
test_command_packages_cmdline (distutils.tests.test_dist.DistributionTestCase) ... ok
test_command_packages_configfile (distutils.tests.test_dist.DistributionTestCase) ... ok
test_command_packages_unspecified (distutils.tests.test_dist.DistributionTestCase) ... ok
test_empty_options (distutils.tests.test_dist.DistributionTestCase) ... ok
test_custom_pydistutils (distutils.tests.test_dist.MetadataTestCase) ... ok
test_obsoletes (distutils.tests.test_dist.MetadataTestCase) ... ok
test_obsoletes_illegal (distutils.tests.test_dist.MetadataTestCase) ... ok
test_provides (distutils.tests.test_dist.MetadataTestCase) ... ok
test_provides_illegal (distutils.tests.test_dist.MetadataTestCase) ... ok
test_requires (distutils.tests.test_dist.MetadataTestCase) ... ok
test_requires_illegal (distutils.tests.test_dist.MetadataTestCase) ... ok
test_simple_metadata (distutils.tests.test_dist.MetadataTestCase) ... ok
test_move_file_verbosity (distutils.tests.test_file_util.FileUtilTestCase) ... ok
test_glob_to_re (distutils.tests.test_filelist.FileListTestCase) ... ok
test_home_installation_scheme (distutils.tests.test_install.InstallTestCase) ... ok
test_user_site (distutils.tests.test_install.InstallTestCase) ... ok
test_simple_run (distutils.tests.test_install_data.InstallDataTestCase) ... ok
test_simple_run (distutils.tests.test_install_headers.InstallHeadersTestCase) ... ok
test_default_settings (distutils.tests.test_install_scripts.InstallScriptsTestCase) ... ok
test_installation (distutils.tests.test_install_scripts.InstallScriptsTestCase) ... ok
test_no_compiler (distutils.tests.test_msvc9compiler.msvc9compilerTestCase) ... ok
test_reg_class (distutils.tests.test_msvc9compiler.msvc9compilerTestCase) ... ok
test_create_pypirc (distutils.tests.test_register.registerTestCase) ... ok
test_password_not_in_file (distutils.tests.test_register.registerTestCase) ... ok
test_password_reset (distutils.tests.test_register.registerTestCase) ... ok
test_registering (distutils.tests.test_register.registerTestCase) ... ok
test_server_empty_registration (distutils.tests.test_register.registerTestCase) ... ok
test_server_registration (distutils.tests.test_register.registerTestCase) ... ok
test_add_defaults (distutils.tests.test_sdist.sdistTestCase) ... ok
test_make_distribution (distutils.tests.test_sdist.sdistTestCase) ... ok
test_prune_file_list (distutils.tests.test_sdist.sdistTestCase) ... ok
test_server_empty_registration (distutils.tests.test_sdist.sdistTestCase) ... ok
test_server_registration (distutils.tests.test_sdist.sdistTestCase) ... ok
test_nt_quote_args (distutils.tests.test_spawn.SpawnTestCase) ... ok
test_customize_compiler (distutils.tests.test_sysconfig.SysconfigTestCase) ... ok
test_get_config_h_filename (distutils.tests.test_sysconfig.SysconfigTestCase) ... ok
test_get_config_vars (distutils.tests.test_sysconfig.SysconfigTestCase) ... ok
test_get_python_inc (distutils.tests.test_sysconfig.SysconfigTestCase) ... ok
test_get_python_lib (distutils.tests.test_sysconfig.SysconfigTestCase) ... ok
test_class (distutils.tests.test_text_file.TextFileTestCase) ... ok
test_finalize_options (distutils.tests.test_upload.uploadTestCase) ... ok
test_saved_password (distutils.tests.test_upload.uploadTestCase) ... ok
test_server_empty_registration (distutils.tests.test_upload.uploadTestCase) ... ok
test_server_registration (distutils.tests.test_upload.uploadTestCase) ... ok
test_upload (distutils.tests.test_upload.uploadTestCase) ... ok
test_change_root (distutils.tests.test_util.utilTestCase) ... ok
test_check_environ (distutils.tests.test_util.utilTestCase) ... ok
test_convert_path (distutils.tests.test_util.utilTestCase) ... ok
test_get_platform (distutils.tests.test_util.utilTestCase) ... ok
test_rfc822_escape (distutils.tests.test_util.utilTestCase) ... ok
test_split_quoted (distutils.tests.test_util.utilTestCase) ... ok
test_strtobool (distutils.tests.test_util.utilTestCase) ... ok
test_cmp (distutils.tests.test_version.VersionTestCase) ... ok
test_cmp_strict (distutils.tests.test_version.VersionTestCase) ... ok
test_prerelease (distutils.tests.test_version.VersionTestCase) ... ok
Doctest: distutils.versionpredicate.VersionPredicate ... ok
Doctest: distutils.versionpredicate.split_provision ... ok

----------------------------------------------------------------------
Ran 93 tests in 0.613s

OK
test_httpservers
test_command (test.test_httpservers.BaseHTTPServerTestCase) ... ok
test_handler (test.test_httpservers.BaseHTTPServerTestCase) ... ok
test_head_keep_alive (test.test_httpservers.BaseHTTPServerTestCase) ... ok
test_header_close (test.test_httpservers.BaseHTTPServerTestCase) ... ok
test_internal_key_error (test.test_httpservers.BaseHTTPServerTestCase) ... ok
test_request_line_trimming (test.test_httpservers.BaseHTTPServerTestCase) ... ok
test_return_custom_status (test.test_httpservers.BaseHTTPServerTestCase) ... ok
test_return_header_keep_alive (test.test_httpservers.BaseHTTPServerTestCase) ... ok
test_send_blank (test.test_httpservers.BaseHTTPServerTestCase) ... ok
test_version_bogus (test.test_httpservers.BaseHTTPServerTestCase) ... ok
test_version_digits (test.test_httpservers.BaseHTTPServerTestCase) ... ok
test_version_invalid (test.test_httpservers.BaseHTTPServerTestCase) ... ok
test_version_none (test.test_httpservers.BaseHTTPServerTestCase) ... ok
test_version_none_get (test.test_httpservers.BaseHTTPServerTestCase) ... ok
test_get (test.test_httpservers.SimpleHTTPServerTestCase) ... ok
test_head (test.test_httpservers.SimpleHTTPServerTestCase) ... ok
test_invalid_requests (test.test_httpservers.SimpleHTTPServerTestCase) ... ok
test_authorization (test.test_httpservers.CGIHTTPServerTestCase) ... ok
test_headers_and_content (test.test_httpservers.CGIHTTPServerTestCase) ... ok
test_invaliduri (test.test_httpservers.CGIHTTPServerTestCase) ... ok
test_no_leading_slash (test.test_httpservers.CGIHTTPServerTestCase) ... ok
test_post (test.test_httpservers.CGIHTTPServerTestCase) ... Traceback (most recent call last):
  File "/private/var/folders/nL/nLe5s1a2G807X4++Ih2+y++++TI/-Tmp-/tmpa3haCf/cgi-bin/file2.py", line 2, in <module>
    import cgi
  File "/Users/dickinsm/svn/python/py3k/Lib/cgi.py", line 34, in <module>
    from operator import attrgetter
ImportError: No module named operator
FAIL
test_url_collapse_path_split (test.test_httpservers.CGIHTTPServerTestCase) ... ok

======================================================================
FAIL: test_post (test.test_httpservers.CGIHTTPServerTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/dickinsm/svn/python/py3k/Lib/test/test_httpservers.py", line 370, in test_post
    self.assertEquals(res.read(), b'1, python, 123456\n')
AssertionError: b'' != b'1, python, 123456\n'

----------------------------------------------------------------------
Ran 23 tests in 10.272s

FAILED (failures=1)
test test_httpservers failed -- Traceback (most recent call last):
  File "/Users/dickinsm/svn/python/py3k/Lib/test/test_httpservers.py", line 370, in test_post
    self.assertEquals(res.read(), b'1, python, 123456\n')
AssertionError: b'' != b'1, python, 123456\n'

1 test OK.
CAUTION:  stdout isn't compared in verbose mode:
a test that passes in verbose mode may fail without it.
1 test failed:
    test_httpservers
Macintosh-4:py3k dickinsm$
msg86426 - (view) Author: Mark Dickinson (mark.dickinson) * (Python committer) Date: 2009-04-24 18:54
On my machine, the failure seems to come down to this:

Macintosh-4:py3k dickinsm$ MACOSX_DEPLOYMENT_TARGET=10.4 ./python.exe
Python 3.1a2+ (py3k:71845M, Apr 24 2009, 19:51:44) 
[GCC 4.0.1 (Apple Inc. build 5490)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import operator
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named operator

test_distutils (specifically, test_get_platform in 
Lib/distutils/tests/test_util.py) sets the MACOSX_DEPLOYMENT_TARGET
environment variable to 10.4;  apparently this affects the 'import 
operator' in test_httpservers.  I've no idea why.
msg86435 - (view) Author: Mark Dickinson (mark.dickinson) * (Python committer) Date: 2009-04-24 22:09
Okay, I think I've got this figured out.  It's a problem in the distutils 
tests: the mechanism for saving and restoring environment variables in

Lib/distutils/tests/test_util.py

doesn't work:  after the line

        self.environ = os.environ

in the setUp method, self.environ and os.environ refer to the same object, 
so restoring using "os.environ = self.environ" doesn't do anything.

The attached patch (against py3k) fixes the problem for me;  trunk also 
appears to have this bug.

Assigning to Tarek.
msg86448 - (view) Author: Walter Dörwald (doerwalter) * (Python committer) Date: 2009-04-25 09:55
There's an EnvironmentVarGuard context manager in support.py that IMHO
should be used for recording changes to the environment variables. Or a
new context manager that does what your patch does could be put into
support.py. There might be other tests that benefit from that.
msg86450 - (view) Author: Walter Dörwald (doerwalter) * (Python committer) Date: 2009-04-25 10:34
Hmm, EnvironmentVarGuard seems to be broken:

import os
from test import support

with support.EnvironmentVarGuard() as env:
   env.unset("HOME")
   env.set("HOME", "bar")

print(os.environ.get("HOME"))

I would have expected that to print the original HOME variable. I'm
going to open a new bug report for that.
msg86453 - (view) Author: Mark Dickinson (mark.dickinson) * (Python committer) Date: 2009-04-25 10:41
EnvironmentVarGuard certainly looks like a good thing to use here, 
provided that it works...
msg86494 - (view) Author: Tarek Ziadé (tarek) * (Python committer) Date: 2009-04-25 12:42
Applied in r71878 and r71879. Thanks

EnvironmentVarGuard is definitely the way to go, I'll use it.
History
Date User Action Args
2022-04-11 14:56:44adminsetgithub: 49201
2009-04-25 12:42:00tareksetstatus: open -> closed

messages: + msg86494
2009-04-25 10:41:19mark.dickinsonsetmessages: + msg86453
2009-04-25 10:34:51doerwaltersetmessages: + msg86450
2009-04-25 09:55:30doerwaltersetnosy: + doerwalter
messages: + msg86448
2009-04-24 22:09:57mark.dickinsonsetfiles: + issue4951.patch
versions: + Python 2.7
messages: + msg86435

assignee: tarek
keywords: + patch
stage: patch review
2009-04-24 18:54:39mark.dickinsonsetmessages: + msg86426
2009-04-24 18:18:52mark.dickinsonsetmessages: + msg86422
2009-04-24 18:14:13mark.dickinsonsetnosy: + mark.dickinson, tarek
messages: + msg86420
2009-03-31 14:27:49ned.deilysetnosy: + ned.deily
messages: + msg84786
2009-03-15 13:47:17gerluijtensetnosy: + gerluijten
messages: + msg83632
2009-01-15 00:13:04pitroucreate