Commit Graph

51 Commits

Author SHA1 Message Date
Serhiy Storchaka 975b94b9de
bpo-45500: Rewrite test_dbm (GH-29002)
* Generate test classes at import time. It allows to filter them when
  run with unittest. E.g: "./python -m unittest test.test_dbm.TestCase_gnu -v".
* Create a database class in a new directory which will be removed after
  test. It guarantees that all created files and directories be removed
  and will not conflict with other dbm tests.
* Restore dbm._defaultmod after tests. Previously it was set to the last
  dbm module (dbm.dumb) which affected other tests.
* Enable the whichdb test for dbm.dumb.
* Move test_keys to the correct test class. It does not test whichdb().
* Remove some outdated code and comments.
2021-10-19 21:11:28 +02:00
Serhiy Storchaka 851811f577
bpo-5846: Do not use obsolete unittest functions. (GH-28303)
Get rid of use of makeSuite() and findTestCases().
Also make test_math and test_threading_local discoverable.
2021-09-13 10:49:53 +03:00
Henry-Joseph Audéoud 707137b863
bpo-40563: Support pathlike objects on dbm/shelve (GH-21849)
Co-authored-by: Hakan Çelik <hakancelik96@outlook.com>
2021-09-10 15:26:16 +03:00
Hai Shi a089d21df1
bpo-40275: Use new test.support helper submodules in tests (GH-21315) 2020-07-06 11:15:08 +02:00
Serhiy Storchaka 9355868458
bpo-41043: Escape literal part of the path for glob(). (GH-20994) 2020-06-20 11:10:31 +03:00
Serhiy Storchaka 22525de737
Use more specific asserts in dbm tests. (GH-7786)
This may help to investigate bpo-33901.
2018-06-19 13:31:48 +03:00
Serhiy Storchaka 6592d7fe11
bpo-33752: Fix a file leak in test_dbm. (GH-7376)
With addCleanup() f.close() was executed after tearDown().
2018-06-05 16:03:00 +03:00
Serhiy Storchaka 70af06cdc4
bpo-31026: Fix test_dbm if dbm.ndbm is build with Berkeley DB. (GH-6632) 2018-04-29 15:45:03 +03:00
Serhiy Storchaka 2e38cc3933
bpo-33383: Fix crash in get() of the dbm.ndbm database object. (#6630) 2018-04-29 12:38:06 +03:00
Berker Peksag 1e8ee9b380 Issue #23277: Remove unused sys and os imports
Patch by Jon Dufresne.
2016-04-24 07:31:42 +03:00
Serhiy Storchaka 8f8ec92de8 Issue #19936: Added executable bits or shebang lines to Python scripts which
requires them.  Disable executable bits and shebang lines in test and
benchmark files in order to prevent using a random system python, and in
source files of modules which don't provide command line interface.  Fixed
shebang lines in the unittestgui and checkpip scripts.
2014-01-16 17:33:23 +02:00
Serhiy Storchaka b992a0e102 Issue #19936: Added executable bits or shebang lines to Python scripts which
requires them.  Disable executable bits and shebang lines in test and
benchmark files in order to prevent using a random system python, and in
source files of modules which don't provide command line interface.  Fixed
shebang line to use python3 executable in the unittestgui script.
2014-01-16 17:15:49 +02:00
Ezio Melotti 9f96789cdc #17198: merge with 3.3. 2013-07-07 13:16:05 +02:00
Ezio Melotti b08495bbcf #17198: Fix a NameError in the dbm module. Patch by Valentina Mukhamedzhanova. 2013-07-07 13:15:08 +02:00
Ezio Melotti c0b64663d9 #17082: merge with 3.3. 2013-03-01 11:24:42 +02:00
Ezio Melotti f79493bf9e #17082: test_dbm* now work with unittest test discovery. Patch by Zachary Ware. 2013-03-01 11:23:28 +02:00
Andrew Svetlov f7a17b48d7 Replace IOError with OSError (#16715) 2012-12-25 16:47:37 +02:00
Victor Stinner bf816223df Issue #12451: Add support.create_empty_file()
We don't need to create a temporary buffered binary or text file object just to
create an empty file.

Replace also os.fdopen(handle).close() by os.close(handle).
2011-06-30 23:25:47 +02:00
briancurtin 525c25d42f Fix #11491. When dbm.open was called with a file which already exists and
the "flag" argument is "n", dbm.error was being raised. As documented,
dbm.open(...,flag='n') will now "Always create a new, empty database,
open for reading and writing", regardless of a previous file existing.
2011-03-14 16:03:54 -04:00
Senthil Kumaran 725c2b9873 Merged revisions 88631 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k

........
  r88631 | senthil.kumaran | 2011-02-26 11:44:03 +0800 (Sat, 26 Feb 2011) | 2 lines

  Fix Issue10228 - Refleak run of test_dbm fails when several dbm modules are available (Patch by Ray.Allen)
........
2011-02-26 07:11:27 +00:00
Benjamin Peterson 90f5ba538b convert shebang lines: python -> python3 2010-03-11 22:53:45 +00:00
Ezio Melotti b58e0bd8bb use assert[Not]In where appropriate 2010-01-23 15:40:09 +00:00
Benjamin Peterson 577473fe68 use assert[Not]In where appropriate
A patch from Dave Malcolm.
2010-01-19 00:09:57 +00:00
Benjamin Peterson c9c0f201fe convert old fail* assertions to assert* 2009-06-30 23:06:06 +00:00
R. David Murray a21e4ca3c6 Merged revisions 70734,70775,70856,70874,70876-70877 via svnmerge
........
  r70734 | r.david.murray | 2009-03-30 15:04:00 -0400 (Mon, 30 Mar 2009) | 7 lines

  Add import_function method to test.test_support, and modify a number of
  tests that expect to be skipped if imports fail or functions don't
  exist to use import_function and import_module.  The ultimate goal is
  to change regrtest to not skip automatically on ImportError.  Checking
  in now to make sure the buldbots don't show any errors on platforms
  I can't direct test on.
........
  r70775 | r.david.murray | 2009-03-30 19:05:48 -0400 (Mon, 30 Mar 2009) | 4 lines

  Change more tests to use import_module for the modules that
  should cause tests to be skipped.  Also rename import_function
  to the more descriptive get_attribute and add a docstring.
........
  r70856 | r.david.murray | 2009-03-31 14:32:17 -0400 (Tue, 31 Mar 2009) | 7 lines

  A few more test skips via import_module, and change import_module to
  return the error message produced by importlib, so that if an import
  in the package whose import is being wrapped is what failed the skip
  message will contain the name of that module instead of the name of the
  wrapped module.  Also fixed formatting of some previous comments.
........
  r70874 | r.david.murray | 2009-03-31 15:33:15 -0400 (Tue, 31 Mar 2009) | 5 lines

  Improve test_support.import_module docstring, remove
  deprecated flag from get_attribute since it isn't likely
  to do anything useful.
........
  r70876 | r.david.murray | 2009-03-31 15:49:15 -0400 (Tue, 31 Mar 2009) | 4 lines

  Remove the regrtest check that turns any ImportError into a skipped test.
  Hopefully all modules whose imports legitimately result in a skipped
  test have been properly wrapped by the previous commits.
........
  r70877 | r.david.murray | 2009-03-31 15:57:24 -0400 (Tue, 31 Mar 2009) | 2 lines

  Add NEWS entry for regrtest change.
........
2009-03-31 23:16:50 +00:00
Benjamin Peterson 1bc15c21d6 fix merge boo-boo 2008-10-11 02:19:18 +00:00
Benjamin Peterson f10a79aad4 merge from trunk 2008-10-11 00:49:57 +00:00
Amaury Forgeot d'Arc b5cf301b8e #3929: dbm.open() would try to raise a tuple. This does not work anymore with python 3.0.
Reviewed by Georg Brandl.
2008-09-25 22:27:43 +00:00
Georg Brandl b17acad68e Make db modules' error classes inherit IOError.
Stop dbm from importing every dbm module when imported.
2008-05-28 08:43:17 +00:00
Georg Brandl 7f986acb01 Rename test file to its proper module name. 2008-05-26 10:30:20 +00:00
Georg Brandl 0a7ac7d70d Create the dbm package from PEP 3108. #2881. 2008-05-26 10:29:35 +00:00
Benjamin Peterson ee8712cda4 #2621 rename test.test_support to test.support 2008-05-20 21:35:26 +00:00
Christian Heimes b186d0084c Merged revisions 61431,61433-61436,61439,61444,61449-61450,61453,61458,61465,61468,61471-61474,61480,61483-61484,61488,61495-61496,61498,61503-61504,61507,61509-61510,61515-61518 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk

........
  r61431 | vinay.sajip | 2008-03-16 22:35:58 +0100 (So, 16 Mär 2008) | 1 line

  Clarified documentation on use of shutdown().
........
  r61433 | mark.summerfield | 2008-03-17 09:28:15 +0100 (Mo, 17 Mär 2008) | 5 lines

  Added a footnote to each pointing out that for XML output if an encoding
  string is given it should conform to the appropriate XML standards---for
  example, "UTF-8" is okay, but "UTF8" is not.
........
  r61434 | eric.smith | 2008-03-17 12:01:01 +0100 (Mo, 17 Mär 2008) | 7 lines

  Issue 2264: empty float presentation type needs to have at least one digit past the decimal point.

  Added "Z" format_char to PyOS_ascii_formatd to support empty float presentation type.
  Renamed buf_size in PyOS_ascii_formatd to more accurately reflect it's meaning.
  Modified format.__float__ to use the new "Z" format as the default.
  Added test cases.
........
  r61435 | eric.smith | 2008-03-17 13:14:29 +0100 (Mo, 17 Mär 2008) | 2 lines

  Reformated lines > 79 chars.
  Deleted unused macro ISXDIGIT.
........
  r61436 | jeffrey.yasskin | 2008-03-17 15:40:53 +0100 (Mo, 17 Mär 2008) | 13 lines

  Allow Gnu gcc's to build python on OSX by removing -Wno-long-double,
  -no-cpp-precomp, and -mno-fused-madd from configure.
   * r22183 added -no-cpp-precomp, which
     http://gcc.gnu.org/ml/gcc/2005-12/msg00368.html claims hasn't been
     needed since gcc-3.1.
   * r25607 added -Wno-long-double to avoid a warning in
     Include/objimpl.h (issue 525481). The long double is still there,
     but OSX 10.4's gcc no longer warns about it.
   * r33666 fixed issue 775892 on OSX 10.3 by adding -mno-fused-madd,
     which changed the sign of some float 0s. Tim Peters said it wasn't
     a real issue anyway, and it no longer causes test failures.
  Fixes issue #1779871.
........
  r61439 | martin.v.loewis | 2008-03-17 17:31:57 +0100 (Mo, 17 Mär 2008) | 2 lines

  Add Trent Nelson.
........
  r61444 | travis.oliphant | 2008-03-17 18:36:12 +0100 (Mo, 17 Mär 2008) | 1 line

  Add necessary headers to back-port new buffer protocol to Python 2.6
........
  r61449 | gregory.p.smith | 2008-03-17 19:48:05 +0100 (Mo, 17 Mär 2008) | 8 lines

  Force zlib.crc32 and zlib.adler32 to return a signed integer on all platforms
  regardless of the native sizeof(long) used in the integer object.

  This somewhat odd behavior of returning a signed is maintained in 2.x for
  compatibility reasons of always returning an integer rather than a long object.

  Fixes Issue1202 for Python 2.6
........
  r61450 | neal.norwitz | 2008-03-17 20:02:45 +0100 (Mo, 17 Mär 2008) | 3 lines

  Use a buffer large enough to ensure we don't overrun, even if the value
  is outside the range we expect.
........
  r61453 | steven.bethard | 2008-03-17 20:33:11 +0100 (Mo, 17 Mär 2008) | 1 line

  Document unicode.isnumeric() and unicode.isdecimal() (issue2326)
........
  r61458 | neal.norwitz | 2008-03-17 21:22:43 +0100 (Mo, 17 Mär 2008) | 5 lines

  Issue 2321: reduce memory usage (increase the memory that is returned
  to the system) by using pymalloc for the data of unicode objects.

  Will backport.
........
  r61465 | martin.v.loewis | 2008-03-17 22:55:30 +0100 (Mo, 17 Mär 2008) | 2 lines

  Add David Wolever.
........
  r61468 | gregory.p.smith | 2008-03-18 01:20:01 +0100 (Di, 18 Mär 2008) | 3 lines

  Fix the IOError message text when opening a file with an invalid filename.
  Error reported by Ilan Schnell.
........
  r61471 | brett.cannon | 2008-03-18 02:00:07 +0100 (Di, 18 Mär 2008) | 2 lines

  Convert test_strftime, test_getargs, and test_pep247 to use unittest.
........
  r61472 | jeffrey.yasskin | 2008-03-18 02:09:59 +0100 (Di, 18 Mär 2008) | 2 lines

  Fix build on platforms that don't have intptr_t. Patch by Joseph Armbruster.
........
  r61473 | brett.cannon | 2008-03-18 02:50:25 +0100 (Di, 18 Mär 2008) | 2 lines

  Convert test_dummy_threading and test_dbm to unittest.
........
  r61474 | brett.cannon | 2008-03-18 02:58:56 +0100 (Di, 18 Mär 2008) | 2 lines

  Move test_extcall to doctest.
........
  r61480 | brett.cannon | 2008-03-18 04:46:22 +0100 (Di, 18 Mär 2008) | 2 lines

  test_errno was a no-op test; now it actually tests things and uses unittest.
........
  r61483 | brett.cannon | 2008-03-18 05:09:00 +0100 (Di, 18 Mär 2008) | 3 lines

  Remove our implementation of memmove() and strerror(); both are in the C89
  standard library.
........
  r61484 | brett.cannon | 2008-03-18 05:16:06 +0100 (Di, 18 Mär 2008) | 2 lines

  The output directory for tests that compare against stdout is now gone!
........
  r61488 | jeffrey.yasskin | 2008-03-18 05:29:35 +0100 (Di, 18 Mär 2008) | 2 lines

  Block the "socket.ssl() is deprecated" warning from test_socket_ssl.
........
  r61495 | jeffrey.yasskin | 2008-03-18 05:56:06 +0100 (Di, 18 Mär 2008) | 4 lines

  Speed test_thread up from 51.328s to 0.081s by reducing its sleep times. We
  still sleep at all to make it likely that all threads are active at the same
  time.
........
  r61496 | jeffrey.yasskin | 2008-03-18 06:12:41 +0100 (Di, 18 Mär 2008) | 4 lines

  Speed up test_dict by about 10x by only checking selected dict literal sizes,
  instead of every integer from 0 to 400. Exhaustive testing wastes time without
  providing enough more assurance that the code is correct.
........
  r61498 | neal.norwitz | 2008-03-18 06:20:29 +0100 (Di, 18 Mär 2008) | 1 line

  Try increasing the timeout to reduce the flakiness of this test.
........
  r61503 | brett.cannon | 2008-03-18 06:43:04 +0100 (Di, 18 Mär 2008) | 2 lines

  Improve the error message for a test that failed on the S-390 Debian buildbot.
........
  r61504 | jeffrey.yasskin | 2008-03-18 06:45:40 +0100 (Di, 18 Mär 2008) | 3 lines

  Add a -S/--slow flag to regrtest to have it print the 10 slowest tests with
  their times.
........
  r61507 | neal.norwitz | 2008-03-18 07:03:46 +0100 (Di, 18 Mär 2008) | 1 line

  Add some info to the failure messages
........
  r61509 | trent.nelson | 2008-03-18 08:02:12 +0100 (Di, 18 Mär 2008) | 1 line

  Issue 2286: bump up the stack size of the 64-bit debug python_d.exe to 2100000.  The default value of 200000 causes a stack overflow at 1965 iterations of r_object() in marshal.c, 35 iterations before the 2000 limit enforced by MAX_MARSHAL_STACK_DEPTH.
........
  r61510 | trent.nelson | 2008-03-18 08:32:47 +0100 (Di, 18 Mär 2008) | 5 lines

  The behaviour of winsound.Beep() seems to differ between different versions of Windows when there's either:
      a) no sound card entirely
      b) legacy beep driver has been disabled
      c) the legacy beep driver has been uninstalled
  Sometimes RuntimeErrors are raised, sometimes they're not.  If _have_soundcard() returns False, don't expect winsound.Beep() to raise a RuntimeError, as this clearly isn't the case, as demonstrated by the various Win32 XP buildbots.
........
  r61515 | martin.v.loewis | 2008-03-18 13:20:15 +0100 (Di, 18 Mär 2008) | 2 lines

  norwitz-amd64 (gentoo) has EREMOTEIO.
........
  r61516 | martin.v.loewis | 2008-03-18 13:45:37 +0100 (Di, 18 Mär 2008) | 2 lines

  Add more Linux error codes.
........
  r61517 | martin.v.loewis | 2008-03-18 14:05:03 +0100 (Di, 18 Mär 2008) | 2 lines

  Add WSA errors.
........
  r61518 | martin.v.loewis | 2008-03-18 14:16:05 +0100 (Di, 18 Mär 2008) | 2 lines

  Note that the stderr output of the test is intentional.
........
2008-03-18 15:15:01 +00:00
Christian Heimes 180510d29b Merged revisions 61189-61190,61192,61194-61195,61198-61199 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk

........
  r61189 | brett.cannon | 2008-03-03 01:38:58 +0100 (Mon, 03 Mar 2008) | 5 lines

  Refactor test_logging to use unittest. This should finally solve the flakiness
  issues.

  Thanks to Antoine Pitrou for the patch.
........
  r61190 | jeffrey.yasskin | 2008-03-03 02:27:03 +0100 (Mon, 03 Mar 2008) | 3 lines

  compile.c always emits END_FINALLY after WITH_CLEANUP, so predict that in
  ceval.c. This is worth about a .03-.04us speedup on a simple with block.
........
  r61192 | brett.cannon | 2008-03-03 03:41:40 +0100 (Mon, 03 Mar 2008) | 4 lines

  Move test_largefile over to using 'with' statements for open files.

  Also rename the driver function to test_main() instead of main_test().
........
  r61194 | brett.cannon | 2008-03-03 04:24:48 +0100 (Mon, 03 Mar 2008) | 3 lines

  Add a note in the main test class' docstring that the order of execution of the
  tests is important.
........
  r61195 | brett.cannon | 2008-03-03 04:26:43 +0100 (Mon, 03 Mar 2008) | 3 lines

  Add a note in the main test class' docstring that the order of execution of the
  tests is important.
........
  r61198 | brett.cannon | 2008-03-03 05:19:29 +0100 (Mon, 03 Mar 2008) | 4 lines

  Add test_main() functions to various tests where it was simple to do. Done so
  that regrtest can execute the test_main() directly instead of relying on import
  side-effects.
........
  r61199 | neal.norwitz | 2008-03-03 05:37:45 +0100 (Mon, 03 Mar 2008) | 1 line

  Only DECREF if ret != NULL
........
2008-03-03 19:15:45 +00:00
Christian Heimes 05e8be17fd Merged revisions 60990-61002 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk

........
  r60990 | eric.smith | 2008-02-23 17:05:26 +0100 (Sat, 23 Feb 2008) | 1 line

  Removed duplicate Py_CHARMASK define.  It's already defined in Python.h.
........
  r60991 | andrew.kuchling | 2008-02-23 17:23:05 +0100 (Sat, 23 Feb 2008) | 4 lines

  #1330538: Improve comparison of xmlrpclib.DateTime and datetime instances.
  Remove automatic handling of datetime.date and datetime.time.
  This breaks backward compatibility, but python-dev discussion was strongly
  against this automatic conversion; see the bug for a link.
........
  r60994 | andrew.kuchling | 2008-02-23 17:39:43 +0100 (Sat, 23 Feb 2008) | 1 line

  #835521: Add index entries for various pickle-protocol methods and attributes
........
  r60995 | andrew.kuchling | 2008-02-23 18:10:46 +0100 (Sat, 23 Feb 2008) | 2 lines

  #1433694: minidom's .normalize() failed to set .nextSibling for last element.
  Fix by Malte Helmert
........
  r61000 | christian.heimes | 2008-02-23 18:40:11 +0100 (Sat, 23 Feb 2008) | 1 line

  Patch #2167 from calvin: Remove unused imports
........
  r61001 | christian.heimes | 2008-02-23 18:42:31 +0100 (Sat, 23 Feb 2008) | 1 line

  Patch #1957: syslogmodule: Release GIL when calling syslog(3)
........
  r61002 | christian.heimes | 2008-02-23 18:52:07 +0100 (Sat, 23 Feb 2008) | 2 lines

  Issue #2051 and patch from Alexander Belopolsky:
  Permission for pyc and pyo files are inherited from the py file.
........
2008-02-23 18:30:17 +00:00
Collin Winter 3add4d78ff Raise statement normalization in Lib/test/. 2007-08-29 23:37:32 +00:00
Guido van Rossum 956e359579 The dbm module should use bytes for keys. This makes test_shelve pass. 2007-08-14 15:42:45 +00:00
Brett Cannon ba7bf49a54 Remove the ability to slice/index on exceptions per PEP 352. 2007-02-27 00:15:55 +00:00
Guido van Rossum be19ed77dd Fix most trivially-findable print statements.
There's one major and one minor category still unfixed:
doctests are the major category (and I hope to be able to augment the
refactoring tool to refactor bona fide doctests soon);
other code generating print statements in strings is the minor category.

(Oh, and I don't know if the compiler package works.)
2007-02-09 05:37:30 +00:00
Guido van Rossum b940e113bf SF patch 1631942 by Collin Winter:
(a) "except E, V" -> "except E as V"
(b) V is now limited to a simple name (local variable)
(c) V is now deleted at the end of the except block
2007-01-10 16:19:56 +00:00
Guido van Rossum f35ad33064 Don't use a fixed temporary name (gdbm).
Don't use our own temp name creation (dbm).
Should be backported to 2.5.
2006-08-25 23:40:32 +00:00
Guido van Rossum e2b70bcf74 Get rid of dict.has_key(). Boy this has a lot of repercussions!
Not all code has been fixed yet; this is just a checkpoint...
The C API still has PyDict_HasKey() and _HasKeyString(); not sure
if I want to change those just yet.
2006-08-18 22:13:04 +00:00
Neal Norwitz e7629c85bc Skip test_dbm if we can't write to the file
Cleanup (remove) the file(s) after we are done with the test.
(Fixes problem on snake farm)
2002-11-02 18:25:08 +00:00
Barry Warsaw 04f357cffe Get rid of relative imports in all unittests. Now anything that
imports e.g. test_support must do so using an absolute package name
such as "import test.test_support" or "from test import test_support".

This also updates the README in Lib/test, and gets rid of the
duplicate data dirctory in Lib/test/data (replaced by
Lib/email/test/data).

Now Tim and Jack can have at it. :)
2002-07-23 19:04:11 +00:00
Guido van Rossum f6e47ad4bd Check that f.keys() == [] right after creation -- this prevents bugs
like the one I just fixed to come back and haunt us.
2001-03-22 00:40:23 +00:00
Fredrik Lundh f785042433 a bold attempt to fix things broken by MAL's verify patch: import
'verify' iff it's used by a test module...
2001-01-17 21:51:36 +00:00
Marc-André Lemburg 3661908a6a This patch removes all uses of "assert" in the regression test suite
and replaces them with a new API verify(). As a result the regression
suite will also perform its tests in optimization mode.

Written by Marc-Andre Lemburg. Copyright assigned to Guido van Rossum.
2001-01-17 19:11:13 +00:00
Fred Drake 57a4e90922 Fix up the cleanup of the temporary DB so it works for BSD DB's
compatibility layer as well as "classic" ndbm.
2000-09-18 17:56:58 +00:00
Guido van Rossum 41360a4696 Mass check-in after untabifying all files that need it. 1998-03-26 19:42:58 +00:00
Roger E. Masse fab8ab8067 Many scripts, but small changes. Update the way the scripts obtain the
'verbose' flag ala GvR updated test harness architecture.

Old way:

	verbose = 0
	if __name__ == '__main__':
		verbose = 1

New way:

	from test_support import verbose

Some other small readablility and functionality updates.
1996-12-20 22:36:52 +00:00