100+ results for '"import unittest" unittest.TestCase self.assert lang:Python'

Not the results you expected?

test_qgsgraph.py (https://github.com/ricardogsilva/Quantum-GIS.git) Python · 335 lines

11 __copyright__ = 'Copyright 2021, The QGIS Project'

12

13 import qgis # NOQA

14 from qgis.analysis import (

15 QgsGraph

16 )

17 from qgis.core import (

18 QgsPointXY

19 )

20 from qgis.testing import start_app, unittest

21

22 start_app()

23

24

25 class TestQgsGraph(unittest.TestCase):

26

27 def test_empty_graph(self):

test_int_literal.py (https://bitbucket.org/glix/python.git) Python · 191 lines

4 """

5

6 import unittest

7 from test import test_support

8

9 import warnings

10 warnings.filterwarnings("ignore", "hex/oct constants", FutureWarning,

11 "<string>")

12

13 class TestHexOctBin(unittest.TestCase):

14

15 def test_hex_baseline(self):

16 # A few upper/lowercase tests

17 self.assertEqual(0x0, 0X0)

18 self.assertEqual(0x1, 0X1)

test_variables.py (https://gitlab.com/abhi1tb/build) Python · 310 lines

1 import unittest

2 import gc

3 from tkinter import (Variable, StringVar, IntVar, DoubleVar, BooleanVar, Tcl,

4 TclError)

5

15

16

17 class TestBase(unittest.TestCase):

18

19 def setUp(self):

307

308 if __name__ == "__main__":

309 from test.support import run_unittest

310 run_unittest(*tests_gui)

PRESUBMIT_test.py (https://github.com/chromium/chromium.git) Python · 231 lines

7 import sys

8 import unittest

9

10 import PRESUBMIT

15

16

17 class CheckNotificationConstructors(unittest.TestCase):

18 """Test the _CheckNotificationConstructors presubmit check."""

19

124

125

126 class CheckCompatibleAlertDialogBuilder(unittest.TestCase):

127 """Test the _CheckCompatibleAlertDialogBuilder presubmit check."""

128

177 self.assertEqual(0, len(errors))

178

179 class CheckBundleUtilsIdentifierName(unittest.TestCase):

180 """Test the _CheckBundleUtilsIdentifierName presubmit check."""

181

test_siemens.py (https://github.com/icometrix/dicom2nifti.git) Python · 206 lines

9 import tempfile

10 import unittest

11

12 import nibabel

25

26

27 class TestConversionSiemens(unittest.TestCase):

28 def test_diffusion_imaging(self):

29 tmp_output_dir = tempfile.mkdtemp()

43 assert_compare_nifti(results['NII_FILE'],

44 ground_thruth_filenames(test_data.SIEMENS_DTI)[0])

45 self.assertTrue(isinstance(results['NII'], nibabel.nifti1.Nifti1Image))

46 assert_compare_bval(results['BVAL_FILE'],

47 ground_thruth_filenames(test_data.SIEMENS_DTI)[2])

55 assert_compare_nifti(results['NII_FILE'],

56 ground_thruth_filenames(test_data.SIEMENS_DTI_IMPLICIT)[0])

57 self.assertTrue(isinstance(results['NII'], nibabel.nifti1.Nifti1Image))

58 assert_compare_bval(results['BVAL_FILE'],

59 ground_thruth_filenames(test_data.SIEMENS_DTI_IMPLICIT)[2])

test_events.py (https://gitlab.com/goolic/pyramid) Python · 301 lines

2 from pyramid import testing

3

4 class NewRequestEventTests(unittest.TestCase):

5 def _getTargetClass(self):

6 from pyramid.events import NewRequest

28 self.assertEqual(inst.request, request)

29

30 class NewResponseEventTests(unittest.TestCase):

31 def _getTargetClass(self):

32 from pyramid.events import NewResponse

201 self.assertEqual(config.subscribed, [(foo, Interface, {'a':1})])

202

203 class TestBeforeRender(unittest.TestCase):

204 def _makeOne(self, system, val=None):

205 from pyramid.events import BeforeRender

tests.py (https://bitbucket.org/zozo123/fuzzywuzzy.git) Python · 285 lines

8 import unittest

9

10 class UtilsTest(unittest.TestCase):

11 def setUp(self):

12 self.s1 = "new york mets"

45 utils.full_process(s)

46

47 class RatioTest(unittest.TestCase):

48

49 def setUp(self):

170 self.assertEqual(best[0], self.baseball_strings[0])

171

172 class ProcessTest(unittest.TestCase):

173

174 def setUp(self):

247 self.assertTrue(best is None)

248 #self.assertIsNone(best) # unittest.TestCase did not have assertIsNone until Python 2.7

249

250 # however if we had no cutoff, something would get returned

update_parser_test.py (https://github.com/sburnett/bismark-passive-server.git) Python · 282 lines

1 import update_parser

2

3 import calendar

4 import unittest

5

6 def format_source(source):

7 return '\n'.join([w.strip() for w in source.splitlines()])

8

9 class TestParser(unittest.TestCase):

10 def test_unanonymized_header(self):

11 source = """9

25 0 0"""

26 update = update_parser.PassiveUpdate(format_source(source))

27 self.assertTrue(update.file_format_version == 9)

28 self.assertTrue(update.build_id == 'BUILDID')

test_qgsnumericformat.py (https://github.com/ricardogsilva/Quantum-GIS.git) Python · 801 lines

11 __copyright__ = 'Copyright 2020, The QGIS Project'

12

13 import qgis # NOQA

14

15 from qgis.core import (QgsFallbackNumericFormat,

24 QgsFractionNumericFormat,

25 QgsReadWriteContext)

26 from qgis.testing import start_app, unittest

27 from qgis.PyQt.QtXml import QDomDocument

51

52

53 class TestQgsNumericFormat(unittest.TestCase):

54

55 def testFallbackFormat(self):

57 f = QgsFallbackNumericFormat()

58 context = QgsNumericFormatContext()

59 self.assertEqual(f.formatDouble(5, context), '5')

60 self.assertEqual(f.formatDouble(5.5, context), '5.5')

test_plot3d.py (https://github.com/thearn/OpenMDAO-Framework.git) Python · 214 lines

6 import os.path

7 import tempfile

8 import shutil

9 import unittest

10

11 from openmdao.lib.datatypes.domain import read_plot3d_q, write_plot3d_q, \

19

20

21 class TestCase(unittest.TestCase):

22 """ Test Plot3D operations on :class:`DomainObj` objects. """

23

155 unformatted=False)

156 test_flow = domain.zone_1.flow_solution

157 self.assertTrue((test_flow.f_1 == wedge_flow.density).all())

158 self.assertTrue((test_flow.f_2 == wedge_flow.momentum.x).all())

test_shell.py (https://github.com/jackingod/mongo.git) Python · 239 lines

22 """

23

24 import unittest

25 import sys

26 import subprocess

27 import os

34 mongo_path = None

35

36 class TestShell(unittest.TestCase):

37

38 def open_mongo(self, args=[]):

52

53 out = mongo_h.communicate()

54 self.assertEqual(out, mongo_help.communicate())

55 self.assert_("usage:" in out[0])

test_principals.py (https://github.com/plone/plone.app.vocabularies.git) Python · 490 lines

1 # -*- coding: utf-8 -*-

2 from plone.app.vocabularies.testing import PAVocabularies_INTEGRATION_TESTING

3

4 import mock

5 import unittest

6

7

8 class PrincipalsTest(unittest.TestCase):

9 layer = PAVocabularies_INTEGRATION_TESTING

10

22

23 def test_empty_principals_vocabulary(self):

24 from plone.app.vocabularies.principals import PrincipalsVocabulary

25

26 vocab = PrincipalsVocabulary([])

test_pcreate.py (https://github.com/ledmonster/pyramid.git) Python · 244 lines

1 import unittest

2

3 class TestPCreateCommand(unittest.TestCase):

4 def setUp(self):

5 from pyramid.compat import NativeIO

6 self.out_ = NativeIO()

7

10

11 def _getTargetClass(self):

12 from pyramid.scripts.pcreate import PCreateCommand

13 return PCreateCommand

14

222

223

224 class Test_main(unittest.TestCase):

225 def _callFUT(self, argv):

226 from pyramid.scripts.pcreate import main

test_routes.py (https://github.com/xaav/pyramid.git) Python · 223 lines

1 import unittest

2

3 from pyramid.tests.test_config import dummyfactory

4 from pyramid.tests.test_config import DummyContext

5

6 class RoutesConfiguratorMixinTests(unittest.TestCase):

7 def _makeOne(self, *arg, **kw):

8 from pyramid.config import Configurator

11

12 def _assertRoute(self, config, name, path, num_predicates=0):

13 from pyramid.interfaces import IRoutesMapper

14 mapper = config.registry.getUtility(IRoutesMapper)

15 routes = mapper.get_routes()

84 request = self._makeRequest(config)

85 request.is_xhr = True

86 self.assertEqual(predicate(None, request), True)

87 request = self._makeRequest(config)

88 request.is_xhr = False

test_recipients.py (https://gitlab.com/yamhill/mailman) Python · 202 lines

18 """Testing various recipients stuff."""

19

20 import unittest

21

22 from mailman.app.lifecycle import create_list

30

31

32 class TestMemberRecipients(unittest.TestCase):

33 """Test regular member recipient calculation."""

34

81

82

83 class TestOwnerRecipients(unittest.TestCase):

84 """Test owner recipient calculation."""

85

test_bus.py (https://github.com/theosp/google_appengine.git) Python · 263 lines

2 import time

3 import unittest

4

5 import cherrypy

11

12

13 class PublishSubscribeTests(unittest.TestCase):

14

15 def get_listener(self, channel, index):

71

72

73 class BusMethodTests(unittest.TestCase):

74

75 def log(self, bus):

122

123 # The stop method MUST call all 'stop' listeners.

124 self.assertEqual(set(self.responses),

125 set([msg % (i, 'stop', None) for i in range(num)]))

126 # The stop method MUST move the state to STOPPED

testArray.py (https://github.com/WeatherGod/numpy.git) Python · 284 lines

1 #! /usr/bin/env python

2 from __future__ import division, absolute_import, print_function

3

4 # System imports

7 import sys

8 import unittest

9

10 # Import NumPy

20 ######################################################################

21

22 class Array1TestCase(unittest.TestCase):

23

24 def setUp(self):

120 ######################################################################

121

122 class Array2TestCase(unittest.TestCase):

123

124 def setUp(self):

ApplyPaalmanPingsCorrectionTest.py (https://github.com/wdzhou/mantid.git) Python · 195 lines

1 from __future__ import (absolute_import, division, print_function)

2

3 import unittest

4 from mantid.kernel import *

5 from mantid.api import *

6 from mantid.simpleapi import (CreateWorkspace, Load, ConvertUnits,

7 SplineInterpolation, ApplyPaalmanPingsCorrection,

8 DeleteWorkspace)

9 import numpy

10

11

12 class ApplyPaalmanPingsCorrectionTest(unittest.TestCase):

13

14 def setUp(self):

test.py (https://github.com/brynmathias/AnalysisV2.git) Python · 352 lines

1 #!/usr/bin/env python

2 import unittest

3

4 from wpolfitter.fit import *

10 (name, a, err, b))

11

12 class MuonTestCase(unittest.TestCase, WPolTestCase):

13 def setUp(self):

14 mu_path = "./ROOTFiles/"

77 self.assertWithinErrors("fR", fR_fit, fR_nom, fR_err)

78 self.assertWithinErrors("f0", f0_fit, f0_nom, f0_err)

79

80 def test_plus_bg(self):

162 self.assertWithinErrors("f0", f0_fit, f0_nom, f0_err)

163

164 class EleTestCase(unittest.TestCase, WPolTestCase):

165 def setUp(self):

166 el_path = "./ROOTFiles/"

test_player.py (https://github.com/pv/pelita.git) Python · 196 lines

1 import unittest

2 from pelita.player import *

5 from pelita.viewer import AsciiViewer

6

7 class TestAbstractPlayer(unittest.TestCase):

8

9 def test_convenience(self):

68 self.assertNotEqual(player_1.current_uni, player_1.universe_states[-2])

69

70 class TestNQRandom_Player(unittest.TestCase):

71 def test_demo_players(self):

72 test_layout = (

81 self.assertEqual(gm.universe.bots[1].current_pos, (4, 1))

82

83 class TestBFS_Player(unittest.TestCase):

84

85 def test_demo_players(self):

test_world.py (https://github.com/mmcgill/bravo.git) Python · 238 lines

13 from bravo.world import World

14

15 class TestWorldChunks(unittest.TestCase):

16

17 def setUp(self):

199 return d

200

201 class TestWorld(unittest.TestCase):

202

203 def setUp(self):

235 @d.addCallback

236 def cb(player):

237 self.assertEqual(player.username, "unittest")

238 return d

239

test_knspace.py (https://github.com/akshayaurora/kivy.git) Python · 247 lines

1

2 import unittest

3 '''ACHTUNG: when testing, never re-use widget names, otherwise the tests

4 may fail as the namespace will remember the names between tests.

6

7

8 class KNSpaceTestCase(unittest.TestCase):

9

10 def test_not_exists(self):

11 from kivy.uix.behaviors.knspace import knspace

12 self.assertRaises(AttributeError, lambda: knspace.label)

13

14 def test_not_exists_property(self):

15 from kivy.uix.behaviors.knspace import knspace

16 self.assertRaises(AttributeError, lambda: knspace.label2)

test_nexus_plugin.py (https://github.com/rnirmal/quantum.git) Python · 286 lines

17 import logging

18 import unittest

19 from quantum.common import exceptions as exc

26

27

28 class TestNexusPlugin(unittest.TestCase):

29

30 def setUp(self):

78 self.assertEqual(new_net_dict[const.NET_NAME], self.net_name)

79 self.assertEqual(new_net_dict[const.NET_VLAN_NAME], self.vlan_name)

80 self.assertEqual(new_net_dict[const.NET_VLAN_ID], self.vlan_id)

102 deleted_net_dict = self._cisco_nexus_plugin.delete_network(

103 tenant_id, new_net_dict[const.NET_ID])

104 self.assertEqual(deleted_net_dict[const.NET_ID], net_id)

105 LOG.debug("test_delete_network - END")

106

test_tableworkspacedisplay_marked_columns.py (https://github.com/mantidproject/mantid.git) Python · 360 lines

8 #

9 #

10 import unittest

11 from itertools import permutations

12

13 from mantidqt.widgets.workspacedisplay.table.error_column import ErrorColumn

14 from mantidqt.widgets.workspacedisplay.table.marked_columns import MarkedColumns

21

22

23 class MarkedColumnsTest(unittest.TestCase):

24

25 def test_add_x(self):

33 def execute_add(self, func_to_add, list_to_check):

34 func_to_add(2)

35 self.assertEqual(1, len(list_to_check))

36 func_to_add(3)

37 self.assertEqual(2, len(list_to_check))

bencode_tests.py (https://gitlab.com/lukaf/python-bittorrent) Python · 464 lines

5 import bencode

6

7 class Walk(unittest.TestCase):

8 """ Check the function walk() works correctly. """

9

98 self.assertEqual(self.n, ["li1ei2ee", "d3:key5:valuee"])

99

100 class Ben_Type(unittest.TestCase):

101 """ Check the function ben_type() works correctly. """

102

435 self.assertEquals(self.n, "d3:key5:valuee")

436

437 class Decode(unittest.TestCase):

438 """ Check the decode() function works. As this dispatches to the other

439 decode functions, we only have to check the dispatching, not the other

test_steps_shellsequence.py (https://gitlab.com/murder187ss/buildbot) Python · 149 lines

13 #

14 # Copyright Buildbot Team Members

15 from twisted.trial import unittest

16

17 from buildbot.process.properties import WithProperties

18 from buildbot.process.results import EXCEPTION

19 from buildbot.process.results import FAILURE

20 from buildbot.process.results import SUCCESS

21 from buildbot.process.results import WARNINGS

22 from buildbot.steps import shellsequence

23 from buildbot.test.fake.remotecommand import Expect

33

34

35 class TestOneShellCommand(steps.BuildStepMixin, unittest.TestCase, configmixin.ConfigErrorsMixin):

36

37 def setUp(self):

test_qgsbookmarkmodel.py (https://github.com/ricardogsilva/Quantum-GIS.git) Python · 248 lines

11 __copyright__ = 'Copyright 2019, The QGIS Project'

12

13 import qgis # NOQA

14

15 from qgis.PyQt.QtCore import Qt, QCoreApplication, QLocale

16

17 from qgis.core import (QgsBookmark,

18 QgsBookmarkManager,

19 QgsBookmarkManagerModel,

24 QgsSettings)

25

26 from qgis.testing import start_app, unittest

27 from utilities import unitTestDataPath

31

32

33 class TestQgsBookmarkManagerModel(unittest.TestCase):

34

35 @classmethod

testMatrix.py (https://github.com/njsmith/numpy.git) Python · 362 lines

1 #! /usr/bin/env python

2 from __future__ import division, absolute_import, print_function

3

4 # System imports

7 import sys

8 import unittest

9

10 # Import NumPy

18 ######################################################################

19

20 class MatrixTestCase(unittest.TestCase):

21

22 def __init__(self, methodName="runTests"):

23 unittest.TestCase.__init__(self, methodName)

24 self.typeStr = "double"

25 self.typeCode = "d"

iq.py (https://github.com/AdamPrzybyla/pyxmpp2.git) Python · 208 lines

3 # pylint: disable=C0111

4

5 import unittest

6

7 from pyxmpp2.etree import ElementTree

8

9 from pyxmpp2.iq import Iq

10 from pyxmpp2.jid import JID

11 from pyxmpp2.stanzapayload import XMLPayload

12 from pyxmpp2.error import StanzaErrorElement

43

44

45 class TestIq(unittest.TestCase):

46 def check_iq1(self, iq):

47 self.assertEqual(iq.from_jid, JID("source@example.com/res"))

test_player.py (https://github.com/FrancescAlted/pelita.git) Python · 196 lines

1 import unittest

2 from pelita.player import *

5 from pelita.viewer import AsciiViewer

6

7 class TestAbstractPlayer(unittest.TestCase):

8

9 def test_convenience(self):

68 self.assertNotEqual(player_1.current_uni, player_1.universe_states[-2])

69

70 class TestNQRandom_Player(unittest.TestCase):

71 def test_demo_players(self):

72 test_layout = (

81 self.assertEqual(gm.universe.bots[1].current_pos, (9, 1))

82

83 class TestBFS_Player(unittest.TestCase):

84

85 def test_demo_players(self):

test_qgsmaplayerproxymodel.py (https://github.com/ricardogsilva/Quantum-GIS.git) Python · 331 lines

11 __copyright__ = 'Copyright 2018, The QGIS Project'

12

13 import qgis # NOQA

14

15 from qgis.core import (

23 from qgis.PyQt.QtCore import Qt, QModelIndex

24

25 from qgis.testing import start_app, unittest

26

27 start_app()

39

40

41 class TestQgsMapLayerProxyModel(unittest.TestCase):

42

43 def testGettersSetters(self):

IndirectFlatPlateAbsorption2Test.py (https://github.com/mantidproject/mantid.git) Python · 164 lines

5 # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS

6 # SPDX - License - Identifier: GPL - 3.0 +

7 import unittest

8 from mantid.simpleapi import LoadNexusProcessed, IndirectFlatPlateAbsorption, DeleteWorkspace

9 from mantid.api import *

10

11

12 class IndirectFlatPlateAbsorption2Test(unittest.TestCase):

13 def setUp(self):

14 """

47

48 y_unit = ws.YUnitLabel()

49 self.assertEqual(y_unit, 'Attenuation factor')

50

51 def test_sample_corrections_only(self):

convert_test.py (https://github.com/beancount/beancount.git) Python · 321 lines

7 import datetime

8 import unittest

9

10 from beancount.core.number import MISSING

36

37

38 class TestPositionConversions(unittest.TestCase):

39 """Test conversions to units, cost, weight and market-value for Position objects."""

40

128 def test_value__no_currency(self):

129 pos = self._pos(A("100 HOOL"), None)

130 self.assertEqual(A("100 HOOL"),

131 convert.get_value(pos, self.PRICE_MAP_EMPTY))

132 self.assertEqual(A("100 HOOL"),

250

251

252 class TestMarketValue(unittest.TestCase):

253

254 @loader.load_doc()

test_pep3118.py (https://gitlab.com/pmuontains/Odoo) Python · 203 lines

1 import unittest

2 from ctypes import *

18 return re.sub(r"\s", "", format)

19

20 class Test(unittest.TestCase):

21

22 def test_native_types(self):

35 self.assertEqual(v.strides, None)

36 # they are always read/write

37 self.assertFalse(v.readonly)

38

39 if v.shape:

41 for dim in v.shape:

42 n = n * dim

43 self.assertEqual(n * v.itemsize, len(v.tobytes()))

44 except:

45 # so that we can see the failing type

test_mbxml.py (https://github.com/lalinsky/picard.git) Python · 429 lines

1 # -*- coding: utf-8 -*-

2

3 import unittest

4 import picard

42

43

44 class TrackTest(unittest.TestCase):

45

46 def test_1(self):

92

93

94 class ReleaseTest(unittest.TestCase):

95

96 def test_1(self):

147

148

149 class ArtistTest(unittest.TestCase):

150

151 def test_1(self):

test_cases.py (https://github.com/lmorchard/home-snippets-server-lib.git) Python · 252 lines

1 import unittest

2 import pdb

157 from nose.util import absfile, src

158 class TC(unittest.TestCase):

159 def runTest(self):

160 raise Exception("error")

205

206 def test_context(self):

207 class TC(unittest.TestCase):

208 def runTest(self):

209 pass

225

226 def test_short_description(self):

227 class TC(unittest.TestCase):

228 def test_a(self):

229 """

tests.py (https://github.com/disko/pyramid_formalchemy.git) Python · 269 lines

1 import unittest2 as unittest

2 from pyramid.config import Configurator

19 dirname = os.path.dirname(dirname)

20

21 class Test_1_UI(unittest.TestCase):

22

23 config = os.path.join(dirname, 'test.ini')

36 # index

37 resp = self.app.get('/admin')

38 self.assertEqual(resp.status_int, 302)

39 assert '/admin/' in resp.location, resp

40

209

210 resp = self.app.get('/admin/Bar', status=403, extra_environ={'REMOTE_USER': 'editor'})

211 self.assertEqual(resp.status_int, 403)

212

213 resp = self.app.get('/admin/Bar', extra_environ={'REMOTE_USER': 'bar_manager'})

hid_gadget_test.py (https://gitlab.com/jonnialva90/iridium-browser) Python · 258 lines

4 # found in the LICENSE file.

5

6 import unittest

7

8 import mock

46

47

48 class HidGadgetTest(unittest.TestCase):

49

50 def test_bad_intervals(self):

135

136

137 class HidFeatureTest(unittest.TestCase):

138

139 def test_disconnected(self):

test_slots.py (https://github.com/mmcgill/bravo.git) Python · 271 lines

30 self.assertRaises(IndexError, self.i.__setitem__, 5, 0 )

31

32 class TestCraftingInternals(unittest.TestCase):

33 def setUp(self):

34 self.i = Crafting()

208 self.assertTrue(self.i.recipe)

209

210 class TestCraftingFurnace(unittest.TestCase):

211 """

212 Test basic crafting functionality.

253 (bravo.blocks.blocks["furnace"].slot, 0, 1))

254

255 class TestChestSerialization(unittest.TestCase):

256 def setUp(self):

257 self.i = ChestStorage()

test_winsound.py (https://github.com/tmacreturns/XBMC_wireless_setup.git) Python · 209 lines

8

9

10 class BeepTest(unittest.TestCase):

11

12 def test_errors(self):

23 winsound.Beep(i, 75)

24

25 class MessageBeepTest(unittest.TestCase):

26

27 def tearDown(self):

49

50

51 class PlaySoundTest(unittest.TestCase):

52

53 def test_errors(self):

test_text.py (https://github.com/akheron/cpython.git) Python · 236 lines

3 Run same tests with both by creating a mixin class.

4 '''

5 import unittest

6 from test.support import requires

92 delete = self.text.delete

93 get = self.text.get

94 Equal = self.assertEqual

95 self.text.insert('1.0', self.hw)

96

192

193

194 class MockTextTest(TextTest, unittest.TestCase):

195

196 @classmethod

215

216

217 class TkTextTest(TextTest, unittest.TestCase):

218

219 @classmethod

test_protocol.py (https://github.com/thirumg/Avro.NET.git) Python · 257 lines

17 Test the protocol parsing logic.

18 """

19 import unittest

20 from avro import protocol

173 VALID_EXAMPLES = [e for e in EXAMPLES if e.valid]

174

175 class TestProtocol(unittest.TestCase):

176 def test_parse(self):

177 print ''

194 fail_msg = "Parse behavior correct on %d out of %d protocols." % \

195 (num_correct, len(EXAMPLES))

196 self.assertEqual(num_correct, len(EXAMPLES), fail_msg)

197

198 def test_valid_cast_to_string_after_parse(self):

220 fail_msg = "Cast to string success on %d out of %d protocols" % \

221 (num_correct, len(VALID_EXAMPLES))

222 self.assertEqual(num_correct, len(VALID_EXAMPLES), fail_msg)

223

224 def test_equivalence_after_round_trip(self):

stencil_cache_block_test.py (https://github.com/richardxia/asp.git) Python · 195 lines

1 import unittest2 as unittest

2 from asp.codegen.cpp_ast import *

5 from stencil_kernel import *

6

7 class StencilConvertASTTests(unittest.TestCase):

8 def setUp(self):

9 class IdentityKernel(StencilKernel):

55

56

57 class StencilConvertASTBlockedTests(unittest.TestCase):

58 def setUp(self):

59 class IdentityKernel(StencilKernel):

87

88

89 class CacheBlockerTests(unittest.TestCase):

90 def test_2d(self):

91 loop = For("i",

test_data_changesources.py (https://gitlab.com/murder187ss/buildbot) Python · 232 lines

27

28

29 class ChangeSourceEndpoint(endpoint.EndpointMixin, unittest.TestCase):

30

31 endpointClass = changesources.ChangeSourceEndpoint

107

108

109 class ChangeSourcesEndpoint(endpoint.EndpointMixin, unittest.TestCase):

110

111 endpointClass = changesources.ChangeSourcesEndpoint

159

160

161 class ChangeSource(interfaces.InterfaceTests, unittest.TestCase):

162

163 def setUp(self):

RequestInfoCollection_t.py (https://github.com/dmwm/WMCore.git) Python · 190 lines

5 from __future__ import division, print_function

6

7 import unittest

8

9 from future.utils import viewvalues

30

31

32 class MyTestCase(unittest.TestCase):

33

34 def setUp(self):

35 if PY3:

36 self.assertItemsEqual = self.assertCountEqual

37

38 def testJobSummary(self):

test.py (https://github.com/GunioRobot/ibus-skk.git) Python · 936 lines

3 from __future__ import with_statement

4 import unittest

5 import os, os.path

6 import skk

7 import nicola

8 from ibus import modifier

9

10 class TestSKK(unittest.TestCase):

11 def setUp(self):

12 # Make sure to start with new empty usrdict.

49 try:

50 usrdict = skk.UsrDict(usrdict_path, 'UTF-8')

51 self.assertNotEqual(usrdict, None)

52 self.assertTrue(usrdict.read_only)

test_pep292.py (https://bitbucket.org/glix/python.git) Python · 194 lines

3 # License: http://www.opensource.org/licenses/PythonSoftFoundation.php

4

5 import unittest

6 from string import Template

21

22

23 class TestTemplate(unittest.TestCase):

24 def test_regular_templates(self):

25 s = Template('$who likes to eat a bag of $what worth $$100')

44

45 def test_percents(self):

46 eq = self.assertEqual

47 s = Template('%(foo)s $foo ${foo}')

48 d = dict(foo='baz')

79

80 def test_invalid_placeholders(self):

81 raises = self.assertRaises

82 s = Template('$who likes $')

83 raises(ValueError, s.substitute, dict(who='tim'))

json3_output_unittest.py (https://github.com/chromium/chromium.git) Python · 205 lines

5 import copy

6 import unittest

7

8 from core.results_processor.formatters import json3_output

9 from core.results_processor import testing

10

11

12 class Json3OutputTest(unittest.TestCase):

13 def setUp(self):

14 self.base_dir = 'base_dir'

20 test_results_copy, self.base_dir, self.test_path_format)

21 # Convert should not modify the original intermediate results.

22 self.assertEqual(test_results_copy, test_results)

23 return results

24

test_codeop.py (https://github.com/rpattabi/ironruby.git) Python · 310 lines

5 import unittest

6 from test.test_support import run_unittest, is_jython, due_to_ironpython_bug, is_cli

7

8 from codeop import compile_command, PyCF_DONT_IMPLY_DEDENT

18 return d

19

20 class CodeopTests(unittest.TestCase):

21

22 def assertValid(self, str, symbol='single'):

58

59 def test_valid(self):

60 av = self.assertValid

61

62 if due_to_ironpython_bug("CodePlex 23740"):

68 compile("pass", "<input>", 'single',

69 PyCF_DONT_IMPLY_DEDENT))

70 self.assertEquals(compile_command("\n"),

71 compile("pass", "<input>", 'single',

72 PyCF_DONT_IMPLY_DEDENT))

unit-writemozinfo.py (https://github.com/jsiu3/mozilla-central.git) Python · 243 lines

2 from __future__ import with_statement

3 import unittest

4 import os, sys, time, tempfile

9 from writemozinfo import build_dict, write_json, JsonValue, jsonify

10

11 class TestBuildDict(unittest.TestCase):

12 def testMissing(self):

13 """

161 self.assertEqual(True, d['crashreporter'])

162

163 class TestJsonValue(unittest.TestCase):

164 def testNone(self):

165 self.assertEqual("null", repr(JsonValue(None)))

185 return eval(j, {'true':True,'false':False,'null':None})

186

187 class TestJsonify(unittest.TestCase):

188 """

189 Test the jsonify function.

ext_version.py (https://github.com/lilydjwg/pyxmpp2.git) Python · 181 lines

3 # pylint: disable=C0111

4

5 import unittest

6 import platform

31 </iq>'''

32

33 class TestVersionPayload(unittest.TestCase):

34 def test_parse_empty(self):

35 element = ElementTree.XML(IQ1)

63 self.stanzas_sent.append(stanza)

64

65 class TestVersionProvider(unittest.TestCase):

66 def test_defaults(self):

67 provider = VersionProvider()

114 "{urn:ietf:params:xml:ns:xmpp-stanzas}service-unavailable")

115

116 class TestVersionRequest(unittest.TestCase):

117 def test_request(self):

118 payload_received = []

test_wsgi.py (https://github.com/daniel-hou0/glance.git) Python · 184 lines

73

74

75 class ResourceTest(unittest.TestCase):

76 def test_get_action_args(self):

77 env = {

122

123

124 class JSONResponseSerializerTest(unittest.TestCase):

125 def test_to_json(self):

126 fixture = {"key": "value"}

138

139

140 class JSONRequestDeserializerTest(unittest.TestCase):

141 def test_has_body_no_content_length(self):

142 request = wsgi.Request.blank('/')

test_util.py (https://github.com/cameronr/pyramid.git) Python · 338 lines

1 import unittest

2

3 class Test__make_predicates(unittest.TestCase):

4 def _callFUT(self, **kw):

5 from pyramid.config.util import make_predicates

6 return make_predicates(**kw)

7

9 order1, _, _ = self._callFUT(xhr=True, request_method='GET')

10 order2, _, _ = self._callFUT(containment=True)

11 self.assertTrue(order1 < order2)

12

13 def test_ordering_number_of_predicates(self):

101 order12, _, _ = self._callFUT(

102 )

103 self.assertEqual(order1, order2)

104 self.assertTrue(order3 > order2)

test_with_pandas.py (https://gitlab.com/github-cloud-corporation/xgboost) Python · 176 lines

1 # -*- coding: utf-8 -*-

2 import numpy as np

3 import xgboost as xgb

4 import testing as tm

5 import unittest

6

7 try:

8 import pandas as pd

9 except ImportError:

18

19

20 class TestPandas(unittest.TestCase):

21

22 def test_pandas(self):

gpu_test_expectations_unittest.py (https://gitlab.com/jonnialva90/iridium-browser) Python · 183 lines

2 # Use of this source code is governed by a BSD-style license that can be

3 # found in the LICENSE file.

4 import unittest

5

6 from telemetry.internal.platform import system_info

70 self.Flaky('wildcardtest*.html', ['win'], bug=123, max_num_retries=7)

71

72 class GpuTestExpectationsTest(unittest.TestCase):

73 def setUp(self):

74 self.expectations = SampleTestExpectations()

122 self.assertExpectationEquals('pass', page,

123 StubPlatform('mac'), VENDOR_AMD, 0x1001)

124 self.assertExpectationEquals('pass', page,

125 StubPlatform('win'), VENDOR_AMD, 0x1002)

126

test_strlit.py (https://bitbucket.org/kbengine/kbengine.git) Python · 186 lines

28 """

29

30 import os

31 import sys

32 import shutil

33 import tempfile

34 import unittest

35 import test.support

62

63

64 class TestLiterals(unittest.TestCase):

65

66 def setUp(self):

test_log.py (https://github.com/coderanger/celery.git) Python · 208 lines

4 import logging

5 import unittest2 as unittest

6 from tempfile import mktemp

46

47

48 class test_default_logger(unittest.TestCase):

49

50 def setUp(self):

76 logger = self.setup_logger(loglevel=logging.ERROR, logfile=None,

77 root=False)

78 self.assertIs(get_handlers(logger)[0].stream, sys.__stderr__,

79 "setup_logger logs to stderr without logfile argument.")

80 self.assertDidLogFalse(logger, "Logging something",

164

165

166 class test_CompatLoggerAdapter(unittest.TestCase):

167 levels = ("debug",

168 "info",

testreducegip.py (https://bitbucket.org/mapdes/ffc.git) Python · 240 lines

22

23 # Pyhton modules

24 import unittest

25 import time

26

27 # FFC modules

28 from ffc.quadrature.symbolics import *

29 from ffc.cpp import format, set_float_formatting

30 from ffc.parameters import FFC_PARAMETERS

31 set_float_formatting(FFC_PARAMETERS['precision'])

32

33 class TestReduceGIP(unittest.TestCase):

34

35 def testReduceGIP(self):

test_solvers.py (https://gitlab.com/christoph-conrads/DCGeig) Python · 486 lines

246

247

248 class Test_solve_with_qr_csd(unittest.TestCase):

249 dtypes = [NP.float32, NP.float64]

250 solver = gep_solvers.qr_csd

341

342

343 class Test_deflate_gep(unittest.TestCase):

344 dtypes = [NP.float32, NP.float64]

345

439

440

441 class Test_solve_with_deflation(unittest.TestCase):

442 dtypes = [NP.float32, NP.float64]

443 solver = gep_solvers.deflation

test_search.py (https://github.com/fetchfans/braintree_python.git) Python · 370 lines

1 from tests.test_helper import *

2

3 class TestSearch(unittest.TestCase):

4 def test_text_node_is(self):

5 credit_card = Customer.create({

26 self.assertTrue(TestHelper.includes(collection, trial_subscription))

27 self.assertFalse(TestHelper.includes(collection, trialless_subscription))

28

29 def test_text_node_is_not(self):

49 ])

50

51 self.assertTrue(TestHelper.includes(collection, trial_subscription))

52 self.assertFalse(TestHelper.includes(collection, trialless_subscription))

202 ])

203

204 self.assertTrue(TestHelper.includes(collection, active_subscription))

205 self.assertFalse(TestHelper.includes(collection, canceled_subscription))

datatests.py (https://github.com/rillian/firefox.git) Python · 237 lines

1 import pymake.data, pymake.functions, pymake.util

2 import unittest

3 import re

42 self.assertEqual(a, e, 'Pattern(%r).subst(%r, %r)' % (s, r, d))

43

44 class LRUTest(unittest.TestCase):

45 # getkey, expected, funccount, debugitems

46 expected = (

122

123

124 class StringExpansionTest(unittest.TestCase):

125 def test_base_expansion_interface(self):

126 s1 = pymake.data.StringExpansion('FOO', None)

138

139

140 class ExpansionTest(unittest.TestCase):

141 def test_is_static_string(self):

142 e1 = pymake.data.Expansion()

test_u2ftoken.py (https://gitlab.com/sheshanarayanag/LinOTP) Python · 343 lines

30 if sys.version_info < (2, 7):

31 try:

32 import unittest2 as unittest

33 except ImportError as exc:

34 print "You need to install unittest2 on Python 2.6. Unittest2 is a "\

35 "backport of new unittest features."

36 raise exc

37 else:

38 import unittest

39

40 from mock import MagicMock, Mock, patch

41

42

43 class U2FTokenClassTestCase(unittest.TestCase):

44

45 """

test_decorators.py (https://github.com/thearn/OpenMDAO-Framework.git) Python · 340 lines

83 super(InheritedDelegateI, self).__init__(parent)

84

85 class DelegateTestCase(unittest.TestCase):

86

87 def test_add_delegate(self):

214 self.assertEqual(delegator.i(delegator.x), 2)

215

216 class StubIfMissingTestCase(unittest.TestCase):

217 def test_stub_class(self):

218 @stub_if_missing_deps('FooBar', 'math', 'blah')

257

258

259 class AcceptsTestCase(unittest.TestCase):

260

261 def test_method_accepts(self):

BoundingBoxTree.py (https://bitbucket.org/pefarrell/dolfin.git) Python · 385 lines

21 # Last changed: 2013-11-14

22

23 import unittest

24 import numpy

29 from dolfin import MPI

30

31 class BoundingBoxTreeTest(unittest.TestCase):

32

33 #--- compute_collisions with point ---

241 first = tree.compute_first_collision(p)

242 if MPI.size(mesh.mpi_comm()) == 1:

243 self.assertIn(first, reference[mesh.topology().dim()])

244

245 def test_compute_first_collision_3d(self):

256 first = tree.compute_first_collision(p)

257 if MPI.size(mesh.mpi_comm()) == 1:

258 self.assertIn(first, reference[dim])

259

260 tree = mesh.bounding_box_tree()

db_mysql.py (https://gitlab.com/pmuontains/Odoo) Python · 165 lines

2 # Written by: F. Gabriel Gosselin <gabrielNOSPAM@evidens.ca>

3 # Based on tests by: aarranz

4 from south.tests import unittest

5

6

9

10

11 class TestMySQLOperations(unittest.TestCase):

12 """MySQL-specific tests"""

13 def setUp(self):

91 db.execute_deferred_sql()

92 constraints = db._find_foreign_constraints(main_table, 'foreign_id')

93 self.assertEquals(len(constraints), 1)

94 db.rename_column(main_table, 'foreign_id', 'reference_id')

95 db.execute_deferred_sql() #Create constraints

test_nailgun_protocol.py (https://gitlab.com/Ivy001/pants) Python · 217 lines

3 # Licensed under the Apache License, Version 2.0 (see LICENSE).

4

5 from __future__ import (absolute_import, division, generators, nested_scopes, print_function,

6 unicode_literals, with_statement)

7

8 import socket

9 import unittest

10

11 import mock

14

15

16 class TestChunkType(unittest.TestCase):

17 def test_chunktype_constants(self):

18 self.assertIsNotNone(ChunkType.ARGUMENT)

28

29

30 class TestNailgunProtocol(unittest.TestCase):

31 EMPTY_PAYLOAD = ''

32 TEST_COMMAND = 'test'

tests.py (https://github.com/fvbock/gDBPool.git) Python · 260 lines

16 sys.path.insert( 0, os.path.dirname( __file__ ).rpartition( '/' )[ 0 ] )

17

18 import unittest

19 import random

20 import logging

21

22 from gevent.select import select

26 from gdbpool.gdbpool_error import DBInteractionException, DBPoolConnectionException, PoolConnectionException, StreamEndException

27 from gdbpool.interaction_pool import DBInteractionPool

28 from gdbpool.connection_pool import DBConnectionPool

36

37

38 class gDBPoolTests( unittest.TestCase ):

39

40 def setUp( self ):

LumiBased_t.py (https://github.com/dmwm/WMCore.git) Python · 307 lines

9 from builtins import next, range

10

11 import unittest

12

13 from WMCore.DataStructs.File import File

14 from WMCore.DataStructs.Fileset import Fileset

15 from WMCore.DataStructs.Job import Job

16 from WMCore.DataStructs.Subscription import Subscription

17 from WMCore.DataStructs.Workflow import Workflow

21 from WMCore.Services.UUIDLib import makeUUID

22

23 class LumiBasedTest(unittest.TestCase):

24 """

25 _LumiBasedTest_

test_numbers.py (https://github.com/jcrobak/hue.git) Python · 230 lines

1 from ctypes import *

2 import unittest

3 import sys, struct

41 ################################################################

42

43 class NumberTestCase(unittest.TestCase):

44

45 def test_default_init(self):

99 # integers cannot be constructed from floats

100 for t in signed_types + unsigned_types:

101 self.assertRaises(TypeError, t, 3.14)

102

103 def test_sizes(self):

122

123 def test_int_from_address(self):

124 from array import array

125 for t in signed_types + unsigned_types:

126 # the array module doesn't suppport all format codes

SpaceGroupTest.py (https://github.com/wdzhou/mantid.git) Python · 164 lines

2 from __future__ import (absolute_import, division, print_function)

3

4 import unittest

5 from mantid.geometry import SpaceGroupFactory, UnitCell

6

7

8 class SpaceGroupTest(unittest.TestCase):

9 def test_creation(self):

10 self.assertRaises(ValueError, SpaceGroupFactory.createSpaceGroup, "none")

28 sg = SpaceGroupFactory.createSpaceGroup('P m -3')

29

30 self.assertTrue(sg.isAllowedUnitCell(cubic))

31 self.assertFalse(sg.isAllowedUnitCell(tetragonal))

40 sgP6m = SpaceGroupFactory.createSpaceGroup('P 6/m')

41

42 self.assertTrue(sgRh.isAllowedUnitCell(rhombohedral))

43 self.assertFalse(sgRh.isAllowedUnitCell(hexagonal))

test_redaction.py (https://gitlab.com/JigmeDatse/synapse) Python · 211 lines

15

16

17 from tests import unittest

18 from twisted.internet import defer

26

27

28 class RedactionTestCase(unittest.TestCase):

29

30 @defer.inlineCallbacks

125 )

126

127 self.assertFalse("redacted_because" in event.unsigned)

128

129 # Redact event

135 event = yield self.store.get_event(msg_event.event_id)

136

137 self.assertEqual(msg_event.event_id, event.event_id)

138

139 self.assertTrue("redacted_because" in event.unsigned)

autodetection.py (https://github.com/jcrobak/hue.git) Python · 233 lines

1 import unittest

2

3 from south.creator.changes import AutoChanges

4

5 class TestComparison(unittest.TestCase):

6

7 """

108 )

109

110 self.assertEqual(

111 AutoChanges.different_attributes(

112 ('django.db.models.fields.CharField', [], {'to': "foo"}),

209 )

210

211 self.assertEqual(

212 AutoChanges.different_attributes(

213 ('models.CharField', ['hah'], {}),

test_fdesc.py (https://github.com/analogue/mythbox.git) Python · 235 lines

18 from twisted.python.util import untilConcludes

19 from twisted.trial import unittest

20

21

22 class ReadWriteTestCase(unittest.TestCase):

23 """

24 Tests for fdesc.readFromFD, fdesc.writeToFD.

110 l = []

111 result = fdesc.readFromFD(self.r, l.append)

112 self.assertEquals(l, [])

113 self.assertEquals(result, None)

177

178

179 class CloseOnExecTests(unittest.TestCase):

180 """

181 Tests for L{fdesc._setCloseOnExec} and L{fdesc._unsetCloseOnExec}.

WMConfigCache_t.py (https://github.com/PerilousApricot/WMCore.git) Python · 213 lines

8 import os

9 import unittest

10 import tempfile

16 from WMQuality.TestInitCouchApp import TestInitCouchApp

17

18 class testWMConfigCache(unittest.TestCase):

19 """

20 _testWMConfigCache_

77 testFlag = True

78

79 self.assertTrue(testFlag)

80

81 return

108 configString2 = configCache2.getConfig()

109

110 self.assertEqual(configString1, configString2)

111 self.assertEqual(configCache2.attachments.get('attach1', None), attach)

unit-Preprocessor.py (https://github.com/diogogmt/mozilla-central.git) Python · 494 lines

1 import unittest

2

3 from StringIO import StringIO

14 StringIO.__init__(self, content)

15

16 class TestPreprocessor(unittest.TestCase):

17 """

18 Unit tests for the Context class

110 ''')

111 self.pp.do_include(f)

112 self.assertEqual(self.pp.out.getvalue(), "PASS\n")

113

114 def test_conditional_not_1(self):

223 ''')

224 self.pp.do_include(f)

225 self.assertEqual(self.pp.out.getvalue(), """You should see two nice ascii tables

226 +-+-+-+

227 | | | |

sdl_keyboard_test.py (https://bitbucket.org/pcraven/pygame2.git) Python · 194 lines

1 import sys

2 import unittest

3 import pygame2.sdl as sdl

4 import pygame2.sdl.rect as rect

5 import pygame2.sdl.keyboard as keyboard

6 import pygame2.sdl.scancode as scancode

7 import pygame2.sdl.keycode as keycode

8 import pygame2.sdl.video as video

9

10

11 class SDLKeyboardTest(unittest.TestCase):

12 __tags__ = ["sdl"]

13

test_qgsmaprenderercache.py (https://github.com/ricardogsilva/Quantum-GIS.git) Python · 318 lines

11 __copyright__ = 'Copyright 2017, The QGIS Project'

12

13 import qgis # NOQA

14

15 from qgis.core import (QgsMapRendererCache,

18 QgsProject,

19 QgsMapToPixel)

20 from qgis.testing import start_app, unittest

21 from qgis.PyQt.QtCore import QCoreApplication

22 from qgis.PyQt.QtGui import QImage

23 from time import sleep

25

26

27 class TestQgsMapRendererCache(unittest.TestCase):

28

29 def testSetCacheImages(self):

test_test_util_validation.py (https://gitlab.com/murder187ss/buildbot) Python · 200 lines

13 #

14 # Copyright Buildbot Team Members

15 import datetime

16

17 from twisted.python import log

18 from twisted.trial import unittest

19

20 from buildbot.test.util import validation

21 from buildbot.util import UTC

22

23

24 class VerifyDict(unittest.TestCase):

25

26 def doValidationTest(self, validator, good, bad):

checker_test.py (https://github.com/emperorcezar/chirpradio-machine.git) Python · 189 lines

1 #!/usr/bin/env python

2

3 import unittest

4 import mutagen.id3

19

20

21 class CheckerTest(unittest.TestCase):

22

23 def setUp(self):

87

88 town_tag.text = [constants.TOWN_FILE_OWNER]

89 self.assertNoTagError(checker.ERROR_TOWN_INCORRECT)

90

91 def test_tpe_tag_checks(self):

92 tpe_tag = mutagen.id3.TPE1(text=["Non-standard artist name"])

93 self.au_file.mutagen_id3.add(tpe_tag)

94 self.assertTagError(checker.ERROR_TPE_NONSTANDARD)

95

96 tpe_tag.text = ["Bob Dylan"]

TestDimensionListModel.py (https://bitbucket.org/cwinkelmann/plista-contest-python.git) Python · 335 lines

4 @author: christian.winkelmann@plista.com

5 '''

6 import unittest

7 import cql

8 from random import uniform

9

10 from plistaContestPy.plistaContestBackend.config import config_global

11 from plistaContestPy.plistaContestBackend.config import config_local

12 from plistaContestPy.plistaContestBackend.real.models.DimensionListModel import DimensionListModel

16

17

18 class TestDimensionListModel(unittest.TestCase):

19 def setUp(self):

20 print "setting up database"

test.py (https://github.com/xuanhan863/pydub.git) Python · 219 lines

1 import unittest

2 import os

8

9

10 class UtilityTests(unittest.TestCase):

11

12 def test_db_float_conversions(self):

20

21

22 class FileAccessTests(unittest.TestCase):

23

24 def setUp(self):

38

39 test1 = test2 = test3 = None

40 class AudioSegmentTests(unittest.TestCase):

41

42 def setUp(self):

DrillExportModelTest.py (https://github.com/mantidproject/mantid.git) Python · 176 lines

8 import unittest

9 from unittest import mock

10

11 from mantidqtinterfaces.drill.model.DrillExportModel import DrillExportModel

12

13

14 class DrillExportModelTest(unittest.TestCase):

15

16 EXPORT_ALGORITHMS = {

94 self.assertEqual(self.exportModel._exportAlgorithms["ea2"], False)

95 self.exportModel.activateAlgorithm("ea2")

96 self.assertEqual(self.exportModel._exportAlgorithms["ea2"], True)

97 self.exportModel.activateAlgorithm("ea2")

98 self.assertEqual(self.exportModel._exportAlgorithms["ea2"], True)

100

101 def test_inactivateAlgorithm(self):

102 self.assertEqual(self.exportModel._exportAlgorithms["ea1"], True)

103 self.exportModel.inactivateAlgorithm("ea1")

104 self.assertEqual(self.exportModel._exportAlgorithms["ea1"], False)

test_action_manager_builder.py (https://github.com/pankajp/pyface.git) Python · 347 lines

1 # Standard library imports.

2 import unittest

3

4 # Enthought library imports.

12

13

14 class ActionManagerBuilderTestCase(unittest.TestCase):

15

16 #### 'TestCase' protocol ##################################################

33

34 if isinstance(first, ActionItem):

35 self.assertEquals(first.action.name, second.action.name)

36

37 elif isinstance(first, ActionManager):

41

42 elif isinstance(first, Group):

43 self.assertEquals(first.separator, second.separator)

44 children1, children2 = first.items, second.items

45

dryrun.py (https://github.com/albermax/innvestigate.git) Python · 338 lines

14 import numpy as np

15 import unittest

16

17 from ...analyzer.base import AnalyzerBase

45

46

47 class BaseLayerTestCase(unittest.TestCase):

48 """

49 A dryrun test on various networks for an analyzing method.

162 self.assertFalse(np.any(np.isnan(analysis.ravel())))

163 self.assertFalse(True)

164

165

166 def test_train_analyzer(method, network_filter):

167 """Workaround for move from unit-tests to pytest."""

168 # todo: Mixing of pytest and unittest is not ideal.

169 # Move completely to pytest.

170 test_case = AnalyzerTrainTestCase(method=method,

test_colorWidgets.py (https://github.com/jackygrahamez/DrugDiscovery-Home.git) Python · 303 lines

13 #

14

15 import sys,unittest,Tkinter

16 from time import sleep

22 sleep(0.1)

23

24 class colorEditorTest(unittest.TestCase):

25

26 #####set and get method tests

119 self.assertEqual(old_rVal!=new_rVal ,True)

120 self.assertEqual(old_gVal!=new_gVal ,True)

121 self.assertEqual(old_bVal!=new_bVal ,True)

269

270

271 class ColorChooserTest(unittest.TestCase):

272

273 def test_colorChooser_1(self):

capabilities.py (https://github.com/jcrobak/hue.git) Python · 289 lines

6

7 """

8 from time import time

9 import array

10 import unittest

11

12

13 class DatabaseTest(unittest.TestCase):

14

15 db_module = None

21

22 def setUp(self):

23 import gc

24 db = self.db_module.connect(*self.connect_args, **self.connect_kwargs)

25 self.connection = db

test_common.py (https://github.com/datakungfu/pandas.git) Python · 296 lines

2 import sys

3

4 import unittest

5

6 from pandas import Series, DataFrame, date_range, DatetimeIndex

49 assert(notnull(idx).all())

50

51 import pandas.lib as lib

52 idx = np.asarray(idx)

53 idx[0] = lib.iNaT

152 assert(result.dtype == np.int32)

153

154 class TestTake(unittest.TestCase):

155

156 def test_1d_with_out(self):

analisadorSintáticoTeste.py (https://gitlab.com/danielbbruno/SimuS) Python · 339 lines

1

2 import unittest

3 from SimuS.compilador import Símbolo, AnalisadorSintático

7 from SimuS.compilador.analisadorLéxicoBase import Símbolo

8

9 class AnalisadorSintáticoCasoDeTeste(unittest.TestCase):

10 def setUp(self):

11 self.mem = Memória(tamanhoDoEndereço = parâmetros.tamanhoDoEndereço,

206 self.assertIn((1, "DW", self.mem.tamanhoDoEndereço, 1), asin.endereçosDasAlocações)

207 self.assertEquals(self.mem.dados, self.novaMem.dados)

208

209 def testeDeslocamento(self):

215 código = [0x20, 0x04 + 5, 0x00, 0xFF]

216 self.novaMem[:len(código)] = código

217 self.assertEquals(self.mem.dados, self.novaMem.dados)

218

219 def testeExceçãoOperandoInválido1(self):

test_package.py (https://github.com/dstuebe/coi-services.git) Python · 368 lines

11 __license__ = 'Apache 2.0'

12

13 from os.path import basename, dirname

14 from os import makedirs

15 from os.path import exists

16 import sys

19 from mock import Mock

20 import unittest

21

22 from pyon.util.log import log

42 @unittest.skip('Skip until moved to MI repo')

43 @attr('UNIT', group='mi')

44 class IDKPackageNose(unittest.TestCase):

45 """

46 Base class for IDK Package Tests

test_assertions.py (https://github.com/alemacgo/pypy.git) Python · 292 lines

1 import datetime

2

3 import unittest

4

5

6 class Test_Assertions(unittest.TestCase):

7 def test_AlmostEqual(self):

8 self.assertAlmostEqual(1.00000001, 1.0)

26 self.assertAlmostEqual(float('inf'), float('inf'))

27 self.assertRaises(self.failureException, self.assertNotAlmostEqual,

28 float('inf'), float('inf'))

29

127

128 def testDefault(self):

129 self.assertFalse(unittest.TestCase.longMessage)

130

131 def test_formatMsg(self):

PoldiCreatePeaksFromFileTest.py (https://github.com/mantidproject/mantid.git) Python · 180 lines

6 # SPDX - License - Identifier: GPL - 3.0 +

7 # pylint: disable=no-init,invalid-name,too-many-public-methods

8 import unittest

9 from testhelpers import assertRaisesNothing

15

16

17 class PoldiCreatePeaksFromFileTest(unittest.TestCase):

18 testname = None

19

20 def __init__(self, *args):

21 unittest.TestCase.__init__(self, *args)

22

23 def test_Init(self):

89 ws = PoldiCreatePeaksFromFile(fileHelper.getName(), 0.7, 10.0)

90

91 self.assertEqual(ws.getNumberOfEntries(), 2)

92 self.assertTrue(ws.contains("SiliconCarbon"))

test_deregister.py (https://gitlab.com/github-cloud-corp/aws-cli) Python · 193 lines

16 from awscli.customizations.codedeploy.deregister import Deregister

17 from awscli.testutils import unittest

18

19

20 class TestDeregister(unittest.TestCase):

21 def setUp(self):

22 self.instance_name = 'instance-name'

105 self.assertIn('tags', self.args)

106 self.assertEquals(self.tags, self.args.tags)

107 self.codedeploy.remove_tags_from_on_premises_instances.\

108 assert_called_with(

186 self.assertFalse(self.iam.delete_user_policy.called)

187 self.assertFalse(self.list_access_keys.paginate.called)

188 self.assertFalse(self.iam.delete_access_key.called)

tests.py (https://github.com/leetrout/django-zebra.git) Python · 365 lines

1 import unittest

2 from django.conf import settings

8 from django.core.urlresolvers import reverse

9

10 class TestWebhooks(unittest.TestCase):

11

12 def setUp(self):

204 zebra_webhook_subscription_trial_ending.connect(self._signal_reciever)

205

206 self.assertEqual(self.signal_kwargs, None)

207

208 # Pulled directly from the stripe docs

274 zebra_webhook_subscription_trial_ending.connect(self._signal_reciever)

275

276 from zebra.models import Customer

277 cust = Customer.objects.create()

278

test_contextlib.py (https://gitlab.com/envieidoc/Clover) Python · 326 lines

4 import tempfile

5 import unittest

6 from contextlib import * # Tests __all__

12

13

14 class ContextManagerTestCase(unittest.TestCase):

15

16 def test_contextmanager_plain(self):

107 self.assertEqual(baz.__doc__, "Whee!")

108

109 class NestedTestCase(unittest.TestCase):

110

111 # XXX This needs more work

220 self.assertEqual(foo(), 1)

221

222 class ClosingTestCase(unittest.TestCase):

223

224 # XXX This needs more work

test_Admin.py (https://github.com/mobyle2-legacy/mobyle2.core.git) Python · 263 lines

7 ########################################################################################

8

9 import unittest2 as unittest

10 import os, sys, stat

11 import shutil

12 from time import mktime

19 sys.path.append(os.path.join(MOBYLEHOME, 'Src'))

20

21 import Mobyle.Test.MobyleTest

22 from Mobyle.MobyleError import MobyleError

24

25

26 class AdminTest(unittest.TestCase):

27

28 def setUp(self):

test_enumerate.py (https://github.com/cguardia/empythoned.git) Python · 255 lines

1 import unittest

2 import sys

62 return self

63

64 class EnumerateTestCase(unittest.TestCase):

65

66 enum = enumerate

108 # Tests an implementation detail where tuple is reused

109 # whenever nothing else holds a reference to it

110 self.assertEqual(len(set(map(id, list(enumerate(self.seq))))), len(self.seq))

111 self.assertEqual(len(set(map(id, enumerate(self.seq)))), min(1,len(self.seq)))

127 res = zip(range(20000), seq)

128

129 class TestReversed(unittest.TestCase):

130

131 def test_simple(self):

test_bipartite.py (https://github.com/igraph/python-igraph.git) Python · 177 lines

1 import unittest

2 from igraph import *

3

4 class BipartiteTests(unittest.TestCase):

5 def testCreateBipartite(self):

6 g = Graph.Bipartite([0, 1]*5, [(0,1),(2,3),(4,5),(6,7),(8,9)])

7 self.assertTrue(g.vcount() == 10 and g.ecount() == 5 and g.is_directed() == False)

8 self.assertTrue(g.is_bipartite())

9 self.assertTrue(g.vs["type"] == [False, True]*5)

10

11 def testFullBipartite(self):

match_syscalls_unittest.py (https://github.com/thiagomanel/Beefs-trace-replayer.git) Python · 130 lines

1 import unittest

2 from match_syscalls import Matcher

4 from match_syscalls import *

5

6 class TestMatchSyscalls(unittest.TestCase):

7

8 # we to match, if it is ok then we do order match, if it ok then we do timing match

54 self.assertEquals(len(matches), 1)

55 (input_call, replayed_call, match, message) = matches[0]

56 self.assertEquals(input_call, r_input[0].original_line)

57 self.assertEquals(replayed_call, str(r_output[0]))

58 self.assertEquals(match, True)

59 self.assertEquals(message, str(0))

60

61 def __input_timestamp__(self, first, second):

test_comparator.py (https://gitlab.com/github-cloud-corp/aws-cli) Python · 235 lines

13 import datetime

14 import unittest

15

16 from mock import Mock

20

21

22 class ComparatorTest(unittest.TestCase):

23 def setUp(self):

24 self.sync_strategy = Mock()

97 for filename in files:

98 result_list.append(filename)

99 self.assertEqual(result_list, ref_list)

100

101 # Now try when the sync strategy says not to sync the file.

106 for filename in files:

107 result_list.append(filename)

108 self.assertEqual(result_list, ref_list)

109

110

project_spec.py (http://mobilegtd.googlecode.com/svn/trunk/) Python · 327 lines

1 import unittest

2 from mock import Mock

3 import model.project

4

5 from model.project import Project

8

9

10 class ProjectClassBehaviour(unittest.TestCase):

11 def setUp(self):

12 self.p_class = Project

18 self.assertTrue(self.observer.notify.called)

19

20 class ProjectBehaviour(unittest.TestCase):

21

22 def setUp(self):

test_shared.py (https://github.com/ynd/Theano.git) Python · 311 lines

1 import numpy

2 import unittest

3

4 import theano

7

8

9 class Test_SharedVariable(unittest.TestCase):

10

11 def test_ctors(self):

152 b = shared(7.234, strict=True)

153 assert b.type == theano.tensor.dscalar

154 self.assertRaises(TypeError, f, b, 8)

155

156 b = shared(numpy.zeros((5, 5), dtype='float32'))

196

197 b = shared(numpy.zeros((5, 5), dtype='float32'))

198 self.assertRaises(TypeError, f, b, numpy.random.rand(5, 5))

199

200 def test_scalar_floatX(self):

test_image_helpers.py (https://github.com/enthought/pyface.git) Python · 202 lines

8 # Thanks for using Enthought open source!

9

10 import unittest

11

12 import wx

19

20

21 class TestImageHelpers(unittest.TestCase):

22

23 def test_image_to_bitmap(self):

133

134 @requires_numpy

135 class TestArrayImageHelpers(unittest.TestCase):

136

137 def test_image_to_array_rgb(self):

test_util.py (https://bitbucket.org/lsun/pyramid.git) Python · 257 lines

1 import unittest

2 from pyramid.compat import PY3

3

4 class Test_InstancePropertyMixin(unittest.TestCase):

5 def _makeOne(self):

6 cls = self._targetClass()

110 self.assertEqual(1, foo.x)

111

112 class Test_WeakOrderedSet(unittest.TestCase):

113 def _makeOne(self):

114 from pyramid.config import WeakOrderedSet

181 self.assertEqual(wos.last, None)

182

183 class Test_object_description(unittest.TestCase):

184 def _callFUT(self, object):

185 from pyramid.util import object_description