Commit Graph

12 Commits

Author SHA1 Message Date
Barry Warsaw 408b6d34de Complete the absolute import patch for the test suite. All relative
imports of test modules now import from the test package.  Other
related oddities are also fixed (like DeprecationWarning filters that
weren't specifying the full import part, etc.).  Also did a general
code cleanup to remove all "from test.test_support import *"'s.  Other
from...import *'s weren't changed.
2002-07-30 23:27:12 +00:00
Guido van Rossum 56ff387a7e Fix for SF bug #472940: can't getattr() attribute shown by dir()
There really isn't a good reason for instance method objects to have
their own __dict__, __doc__ and __name__ properties that just delegate
the request to the function (callable); the default attribute behavior
already does this.

The test suite had to be fixed because the error changes from
TypeError to AttributeError.
2001-10-22 02:00:09 +00:00
Guido van Rossum db2a902dee Undo some (but not all) of the more lenient acceptance of
(AttributeError, TypeError) -- the leniency wasn't needed everywhere.
2001-09-18 03:55:22 +00:00
Guido van Rossum bd13149711 - Some tests that check that assignments are not allowed expect this
to raise TypeError.  In practice, a disallowed attribute assignment
  can raise either TypeError or AttributeError (and it's unclear which
  is better).  So allow either.  (Yes, this is in anticipation of a
  code change that switches the exception raised. :-)

- Add a utility function, cantset(), which verifies that setting a
  particular attribute to a given value is disallowed, and also that
  deleting that same attribute is disallowed.  Use this in the
  test_func_*() tests.

- Add a new set of tests that test conformance of various instance
  method attributes.  (Also in anticipation of code that changes their
  implementation.)
2001-09-18 03:28:54 +00:00
Guido van Rossum d9d1d4ac6f Rewrite function attributes to use the generic routines properly.
This uses the new "restricted" feature of structmember, and getset
descriptors for some of the type checks.
2001-09-17 23:46:56 +00:00
Barry Warsaw 033daa49ea Test the new semantics for setting and deleting a function's __dict__
attribute.  Deleting it, or setting it to a non-dictionary result in a
TypeError.  Note that getting it the first time magically initializes
it to an empty dict so that func.__dict__ will always appear to be a
dictionary (never None).

Closes SF bug #446645.
2001-08-14 18:28:28 +00:00
Barry Warsaw c1e100f215 Additional tests for current, PEP described semantics:
- func.__dict__ is None until the first attribute is assigned

- del func.__dict__ is equivalent to func.__dict__ = None

- disallowing assignment to function attribute through unbound method
  (it was always illegal to assign through bound method).

- verifying that setting attribute explicitly on underlying function
  via meth.im_func is okay.
2001-02-26 18:07:26 +00:00
Tim Peters 10fb386399 Whitespace normalization. 2001-02-09 20:17:14 +00:00
Moshe Zadka 497671e094 The one thing I love more then writing code is deleting code.
* Removed func_hash and func_compare, so they can be treated as immutable
  content-less objects (address hash and comparison)
* Added tests to that affect to test_funcattrs (also testing func_code
  is writable)
* Reverse meaning of tests in test_opcodes which checked identical code
  gets identical functions
2001-01-29 06:21:17 +00:00
Barry Warsaw 2e9b396740 Add some regression tests of coredump bugs in funcobject.c 2.31. Also
added a test of a coredump that would occur when del'ing
func_defaults (put here for convenience).
2001-01-19 19:55:12 +00:00
Barry Warsaw 534c60f9ab Add a test case suggested by Guido, where a method is created with the
new module.
2001-01-15 21:00:02 +00:00
Barry Warsaw 4a420a0a75 Committing PEP 232, function attribute feature, approved by Guido.
Closes SF patch #103123.

Regression test for function attributes, with output file.
2001-01-15 20:30:15 +00:00