[issue1006] Refactor test_winreg.py to use unittest.

2007-08-23 Thread Atul Varma

New submission from 
Atul Varma
:

This patch refactors test_winreg.py to use unittest.  When this patch is
applied, Lib/test/output/test_winreg can be removed.

I also made a few formatting changes to ensure that all lines are
constrained to 80-characters.

The original test_winreg.py took a command-line argument, "--remote", to
specify the name of a remote computer to run tests on.  For now, I've
added a unittest test called "testRemoteMachineRegistryWorks" which
raises a test_support.TestSkipped exception if the "--remote" argument
wasn't specified.  I'm not sure if this is optimal behavior; it can be
changed if not, of course.

--
components: Tests
files: refactor_test_winreg.py.patch
messages: 55232
nosy: varmaa
severity: normal
status: open
title: Refactor test_winreg.py to use unittest.
versions: Python 2.6

__
Tracker <[EMAIL PROTECTED]>
<http://bugs.python.org/issue1006>
__

refactor_test_winreg.py.patch
Description: Binary data
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1008] Refactor test_signal.py to use unittest.

2007-08-23 Thread Atul Varma

New submission from Atul Varma:

This patch refactors test_signal.py to use unittest.  When this patch is
applied, Lib/test/output/test_signal can be removed.

I tried to refactor out individual tests from the original script and
place them in separate test cases.

--
components: Tests
files: refactored_test_signal.py.patch
messages: 55235
nosy: varmaa
severity: normal
status: open
title: Refactor test_signal.py to use unittest.
versions: Python 2.6

__
Tracker <[EMAIL PROTECTED]>
<http://bugs.python.org/issue1008>
__--- test_signal.py	2007-07-12 18:54:12.0 -0500
+++ test_signal_new.py	2007-07-13 03:13:00.0 -0500
@@ -1,167 +1,179 @@
-# Test the signal module
-from test.test_support import verbose, TestSkipped, TestFailed, vereq
+import unittest
+from test import test_support
 import signal
 import os, sys, time
 
-if sys.platform[:3] in ('win', 'os2') or sys.platform=='riscos':
-raise TestSkipped, "Can't test signal on %s" % sys.platform
+class InterProcessSignalTests(unittest.TestCase):
+MAX_DURATION = 20   # Entire test should last at most 20 sec.
 
-MAX_DURATION = 20   # Entire test should last at most 20 sec.
+# Set up a child to send signals to us (the parent) after waiting
+# long enough to receive the alarm.  It seems we miss the alarm
+# for some reason.  This will hopefully stop the hangs on
+# Tru64/Alpha.  Alas, it doesn't.  Tru64 appears to miss all the
+# signals at times, or seemingly random subsets of them, and
+# nothing done in force_test_exit so far has actually helped.
+def spawn_force_test_exit_process(self, parent_pid):
+# Sigh, both imports seem necessary to avoid errors.
+import os
+fork_pid = os.fork()
+if fork_pid:
+# In parent.
+return fork_pid
+
+# In child.
+import os, time
+try:
+# Wait 5 seconds longer than the expected alarm to give
+# enough time for the normal sequence of events to occur.
+# This is just a stop-gap to try to prevent the test from
+# hanging.
+time.sleep(self.MAX_DURATION + 5)
+print >> sys.__stdout__, '  child should not have to kill parent'
+for signame in "SIGHUP", "SIGUSR1", "SIGUSR2", "SIGALRM":
+os.kill(parent_pid, getattr(signal, signame))
+print >> sys.__stdout__, "child sent", signame, "to", \
+  parent_pid
+time.sleep(1)
+finally:
+os._exit(0)
 
-if verbose:
-x = '-x'
-else:
-x = '+x'
-
-pid = os.getpid()
-if verbose:
-print "test runner's pid is", pid
-
-# Shell script that will send us asynchronous signals
-script = """
- (
-set %(x)s
-sleep 2
-kill -HUP %(pid)d
-sleep 2
-kill -USR1 %(pid)d
-sleep 2
-kill -USR2 %(pid)d
- ) &
-""" % vars()
-
-a_called = b_called = False
-
-def handlerA(*args):
-global a_called
-a_called = True
-if verbose:
-print "handlerA invoked", args
-
-class HandlerBCalled(Exception):
-pass
-
-def handlerB(*args):
-global b_called
-b_called = True
-if verbose:
-print "handlerB invoked", args
-raise HandlerBCalled, args
-
-# Set up a child to send signals to us (the parent) after waiting long
-# enough to receive the alarm.  It seems we miss the alarm for some
-# reason.  This will hopefully stop the hangs on Tru64/Alpha.
-# Alas, it doesn't.  Tru64 appears to miss all the signals at times, or
-# seemingly random subsets of them, and nothing done in force_test_exit
-# so far has actually helped.
-def force_test_exit():
-# Sigh, both imports seem necessary to avoid errors.
-import os
-fork_pid = os.fork()
-if fork_pid:
-# In parent.
-return fork_pid
-
-# In child.
-import os, time
-try:
-# Wait 5 seconds longer than the expected alarm to give enough
-# time for the normal sequence of events to occur.  This is
-# just a stop-gap to try to prevent the test from hanging.
-time.sleep(MAX_DURATION + 5)
-print >> sys.__stdout__, '  child should not have to kill parent'
-for signame in "SIGHUP", "SIGUSR1", "SIGUSR2", "SIGALRM":
-os.kill(pid, getattr(signal, signame))
-print >> sys.__stdout__, "child sent", signame, "to", pid
-time.sleep(1)
-finally:
-os._exit(0)
-
-# Install handlers.
-hup = signal.signal(signal.SIGHUP, handlerA)
-usr1 = signal.signal(signal.SIGUSR1, handlerB)
-usr2 = si

[issue2136] urllib2 basic auth handler doesn't handle realm names in single-quoted strings

2008-02-17 Thread Atul Varma

New submission from Atul Varma:

This isn't necessarily a bug in Python--it's really a bug in websites
that produce what are technically malformed WWW-Authenticate headers, I
believe.

According to RFC 2617, a WWW-Authenticate header should be of the form:

  WWW-Authenticate: Basic realm="Private"

However, some websites, produce the header using single-quotes:

  WWW-Authenticate: Basic realm='Private'

The Firefox browser deals with this gracefully, but Python's urllib2
does not; specifically, an AbstractBasicAuthHandler does not recognize
the second type of header as an auth header at all, and as a result it's
impossible to access sites protected with such headers.

The attached patch alters the behavior of the class to deal with this
situation gracefully, and also adds a unit test to ensure that the
functionality works.

Implementation notes: This isn't the most well-engineered fix in the
world; in particular, I didn't change the regex used to parse
WWW-Authenticate headers, in part because (A) such a regex was difficult
to compose and (B) it would've been quite difficult to read, and I
didn't want to inadvertently mess up the current behavior of the code.

--
components: Library (Lib)
files: urllib2_single_quoted_auth_fix.patch
messages: 62513
nosy: varmaa
severity: minor
status: open
title: urllib2 basic auth handler doesn't handle realm names in single-quoted 
strings
type: behavior
versions: Python 2.6
Added file: http://bugs.python.org/file9455/urllib2_single_quoted_auth_fix.patch

__
Tracker <[EMAIL PROTECTED]>
<http://bugs.python.org/issue2136>
__
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue2465] sphinx-quickstart.py still creates makefile even if user tells it not to

2008-03-23 Thread Atul Varma

New submission from Atul Varma <[EMAIL PROTECTED]>:

If the user chooses not to have Sphinx create a Makefile, Sphinx still
behaves as though the user wants it to create one.  This patch provides
a simple fix.

--
assignee: georg.brandl
components: Documentation tools (Sphinx)
files: sphinx-quickstart-makefile.patch
keywords: patch
messages: 64369
nosy: georg.brandl, varmaa
severity: normal
status: open
title: sphinx-quickstart.py still creates makefile even if user tells it not to
type: behavior
versions: Python 2.5
Added file: http://bugs.python.org/file9830/sphinx-quickstart-makefile.patch

__
Tracker <[EMAIL PROTECTED]>
<http://bugs.python.org/issue2465>
__
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com