Merge pull request #1530 from youknowone/test-names

Rename some test filenames by convention
This commit is contained in:
Windel Bouwman
2019-10-14 20:18:30 +02:00
committed by GitHub
24 changed files with 61 additions and 64 deletions

View File

@@ -129,4 +129,25 @@ assert '(1-1j)' == repr(1-1j)
# __getnewargs__
assert (3 + 5j).__getnewargs__() == (3.0, 5.0)
assert (5j).__getnewargs__() == (0.0, 5.0)
assert (5j).__getnewargs__() == (0.0, 5.0)
class Complex():
def __init__(self, real, imag):
self.real = real
self.imag = imag
def __repr__(self):
return "Com" + str((self.real, self.imag))
def __sub__(self, other):
return Complex(self.real - other, self.imag)
def __rsub__(self, other):
return Complex(other - self.real, -self.imag)
def __eq__(self, other):
return self.real == other.real and self.imag == other.imag
assert Complex(4, 5) - 3 == Complex(1, 5)
assert 7 - Complex(4, 5) == Complex(3, -5)

View File

@@ -51,3 +51,22 @@ assert_raises(TypeError, pow, 2, 4.0, 5)
assert_raises(TypeError, pow, 2.0, 4, 5)
assert_raises(ValueError, pow, 2, -1, 5)
assert_raises(ValueError, pow, 2, 2, 0)
# bitwise
assert 8 >> 3 == 1
assert 8 << 3 == 64
# Left shift raises type error
assert_raises(TypeError, lambda: 1 << 0.1)
assert_raises(TypeError, lambda: 1 << "abc")
# Right shift raises type error
assert_raises(TypeError, lambda: 1 >> 0.1)
assert_raises(TypeError, lambda: 1 >> "abc")
# Left shift raises value error on negative
assert_raises(ValueError, lambda: 1 << -1)
# Right shift raises value error on negative
assert_raises(ValueError, lambda: 1 >> -1)

View File

@@ -337,3 +337,23 @@ assert frozenset([1, 2]).__ne__(frozenset())
assert not frozenset([1, 2]).__ne__(set([2, 1]))
assert not frozenset([1, 2]).__ne__(frozenset([2, 1]))
assert frozenset().__ne__(1) == NotImplemented
empty_set = set()
non_empty_set = set([1,2,3])
set_from_literal = {1,2,3}
assert 1 in non_empty_set
assert 4 not in non_empty_set
assert 1 in set_from_literal
assert 4 not in set_from_literal
# TODO: Assert that empty aruguments raises exception.
non_empty_set.add('a')
assert 'a' in non_empty_set
# TODO: Assert that empty arguments, or item not in set raises exception.
non_empty_set.remove(1)
assert 1 not in non_empty_set
# TODO: Assert that adding the same thing to a set once it's already there doesn't do anything.

View File

@@ -1,4 +1,3 @@
# This probably will be superceeded by the python unittests when that works.
import xdrlib

View File

@@ -1,21 +0,0 @@
assert 5 - 3 == 2
class Complex():
def __init__(self, real, imag):
self.real = real
self.imag = imag
def __repr__(self):
return "Com" + str((self.real, self.imag))
def __sub__(self, other):
return Complex(self.real - other, self.imag)
def __rsub__(self, other):
return Complex(other - self.real, -self.imag)
def __eq__(self, other):
return self.real == other.real and self.imag == other.imag
assert Complex(4, 5) - 3 == Complex(1, 5)
assert 7 - Complex(4, 5) == Complex(3, -5)

View File

@@ -1,21 +0,0 @@
from testutils import assert_raises
#
# Tests
#
assert 8 >> 3 == 1
assert 8 << 3 == 64
# Left shift raises type error
assert_raises(TypeError, lambda: 1 << 0.1)
assert_raises(TypeError, lambda: 1 << "abc")
# Right shift raises type error
assert_raises(TypeError, lambda: 1 >> 0.1)
assert_raises(TypeError, lambda: 1 >> "abc")
# Left shift raises value error on negative
assert_raises(ValueError, lambda: 1 << -1)
# Right shift raises value error on negative
assert_raises(ValueError, lambda: 1 >> -1)

View File

@@ -1,20 +0,0 @@
empty_set = set()
non_empty_set = set([1,2,3])
set_from_literal = {1,2,3}
assert 1 in non_empty_set
assert 4 not in non_empty_set
assert 1 in set_from_literal
assert 4 not in set_from_literal
# TODO: Assert that empty aruguments raises exception.
non_empty_set.add('a')
assert 'a' in non_empty_set
# TODO: Assert that empty arguments, or item not in set raises exception.
non_empty_set.remove(1)
assert 1 not in non_empty_set
# TODO: Assert that adding the same thing to a set once it's already there doesn't do anything.