Skip to content

Commit 1e328b2

Browse files
committed
Replace deprecated failIf, failUnless functions.
Use recommended TestCase functions assertFalse, assertTrue instead. No change in code function.
1 parent 86b78bd commit 1e328b2

File tree

7 files changed

+111
-111
lines changed

7 files changed

+111
-111
lines changed

diffpy/Structure/tests/TestLattice.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ def test_latpar_properties(self):
9494
lat.gamma = 120
9595
lat1 = Lattice(2, 4, 6, 80, 100, 120)
9696
self.assertAlmostEqual(-0.5, lat.cg, self.places)
97-
self.failUnless(numpy.array_equal(lat1.base, lat.base))
97+
self.assertTrue(numpy.array_equal(lat1.base, lat.base))
9898
return
9999

100100

diffpy/Structure/tests/TestLoadStructure.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def test_xcfg(self):
1717
"""
1818
f = datafile('BubbleRaftShort.xcfg')
1919
stru = loadStructure(f)
20-
self.failUnless(type(stru) is Structure)
20+
self.assertTrue(type(stru) is Structure)
2121
self.assertRaises(StructureFormatError,
2222
loadStructure, f, 'xyz')
2323
return
@@ -27,16 +27,16 @@ def test_discus(self):
2727
"""
2828
f = datafile('Ni-discus.stru')
2929
stru = loadStructure(f)
30-
self.failUnless(type(stru) is PDFFitStructure)
30+
self.assertTrue(type(stru) is PDFFitStructure)
3131
return
3232

3333
def test_cif(self):
3434
"""check loading of CIF file format
3535
"""
3636
f = datafile('PbTe.cif')
3737
stru = loadStructure(f)
38-
self.failUnless(isinstance(stru, Structure))
39-
self.failIf(isinstance(stru, PDFFitStructure))
38+
self.assertTrue(isinstance(stru, Structure))
39+
self.assertFalse(isinstance(stru, PDFFitStructure))
4040
return
4141

4242
def test_badfile(self):

diffpy/Structure/tests/TestP_cif.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ def test_write_and_read(self):
206206
a0 = stru[0]
207207
self.assertEqual('Cd', a0.element)
208208
self.assertListAlmostEqual([0.3334, 0.6667, 0.0], a0.xyz)
209-
self.failUnless(a0.anisotropy)
209+
self.assertTrue(a0.anisotropy)
210210
self.assertAlmostEqual(0.01303, a0.U[0,0])
211211
self.assertAlmostEqual(0.01303, a0.U[1,1])
212212
self.assertAlmostEqual(0.01402, a0.U[2,2])

diffpy/Structure/tests/TestP_discus.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ def test_read_discus_Ni(self):
6060
# first atom
6161
a0 = stru[0]
6262
self.assertEqual((0.0, 0.0, 0.0), tuple(a0.xyz))
63-
self.failUnless(not a0.anisotropy)
63+
self.assertTrue(not a0.anisotropy)
6464
Biso0 = 0.1
6565
self.assertAlmostEqual(Biso0, a0.Bisoequiv, self.places)
6666
return
@@ -117,11 +117,11 @@ def test_spdiameter_parsing(self):
117117
stru.read(datafile('Ni-discus.stru'), self.format)
118118
self.assertEqual(0, stru.pdffit['spdiameter'])
119119
snoshape = stru.writeStr(format=self.format)
120-
self.failUnless(not re.search('(?m)^shape', snoshape))
120+
self.assertTrue(not re.search('(?m)^shape', snoshape))
121121
# produce a string with non-zero spdiameter
122122
stru.pdffit['spdiameter'] = 13
123123
s13 = stru.writeStr(format=self.format)
124-
self.failUnless(re.search('(?m)^shape +sphere, ', s13))
124+
self.assertTrue(re.search('(?m)^shape +sphere, ', s13))
125125
stru13 = Structure()
126126
stru13.readStr(s13)
127127
self.assertEqual(13, stru13.pdffit['spdiameter'])
@@ -140,11 +140,11 @@ def test_stepcut_parsing(self):
140140
stru.read(datafile('Ni-discus.stru'), self.format)
141141
self.assertEqual(0, stru.pdffit['stepcut'])
142142
snoshape = stru.writeStr(format=self.format)
143-
self.failUnless(not re.search('(?m)^shape', snoshape))
143+
self.assertTrue(not re.search('(?m)^shape', snoshape))
144144
# produce a string with non-zero stepcut
145145
stru.pdffit['stepcut'] = 13
146146
s13 = stru.writeStr(format=self.format)
147-
self.failUnless(re.search('(?m)^shape +stepcut, ', s13))
147+
self.assertTrue(re.search('(?m)^shape +stepcut, ', s13))
148148
stru13 = Structure()
149149
stru13.readStr(s13)
150150
self.assertEqual(13, stru13.pdffit['stepcut'])

diffpy/Structure/tests/TestP_pdffit.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -199,11 +199,11 @@ def test_spdiameter_parsing(self):
199199
stru.read(datafile('Ni.stru'), self.format)
200200
self.assertEqual(0, stru.pdffit['spdiameter'])
201201
snoshape = stru.writeStr(format=self.format)
202-
self.failUnless(not re.search('(?m)^shape', snoshape))
202+
self.assertTrue(not re.search('(?m)^shape', snoshape))
203203
# produce a string with non-zero spdiameter
204204
stru.pdffit['spdiameter'] = 13
205205
s13 = stru.writeStr(format=self.format)
206-
self.failUnless(re.search('(?m)^shape +sphere, ', s13))
206+
self.assertTrue(re.search('(?m)^shape +sphere, ', s13))
207207
stru13 = Structure()
208208
stru13.readStr(s13)
209209
self.assertEqual(13, stru13.pdffit['spdiameter'])
@@ -222,11 +222,11 @@ def test_stepcut_parsing(self):
222222
stru.read(datafile('Ni.stru'), self.format)
223223
self.assertEqual(0, stru.pdffit['stepcut'])
224224
snoshape = stru.writeStr(format=self.format)
225-
self.failUnless(not re.search('(?m)^shape', snoshape))
225+
self.assertTrue(not re.search('(?m)^shape', snoshape))
226226
# produce a string with non-zero stepcut
227227
stru.pdffit['stepcut'] = 13
228228
s13 = stru.writeStr(format=self.format)
229-
self.failUnless(re.search('(?m)^shape +stepcut, ', s13))
229+
self.assertTrue(re.search('(?m)^shape +stepcut, ', s13))
230230
stru13 = Structure()
231231
stru13.readStr(s13)
232232
self.assertEqual(13, stru13.pdffit['stepcut'])

0 commit comments

Comments
 (0)