Best Python code snippet using pytest-django_python
log.py
Source:log.py
1import unittest2from backupdb.utils.log import bar3class BarTestCase(unittest.TestCase):4 def test_it_should_return_a_string_with_text_centered_in_a_bar(self):5 self.assertEqual(6 bar('test', width=70),7 '================================ test ================================',8 )9 def test_it_should_return_a_bar_string_with_the_specified_width(self):10 test_bar1 = r'=========================== test ==========================='11 test_bar2 = r'//========================= test =========================\\'12 test_bar3 = r'\\========================= test =========================//'13 self.assertEqual(len(test_bar1), 60)14 self.assertEqual(len(test_bar2), 60)15 self.assertEqual(len(test_bar3), 60)16 self.assertEqual(bar('test', width=60), test_bar1)17 self.assertEqual(bar('test', width=60, position='top'), test_bar2)18 self.assertEqual(bar('test', width=60, position='bottom'), test_bar3)19 def test_it_should_work_even_if_the_given_width_is_less_than_the_message_length(self):20 self.assertEqual(bar('test', width=0), '== test ==')21 self.assertEqual(bar('test', width=0, position='top'), r'// test \\')22 self.assertEqual(bar('test', width=0, position='bottom'), r'\\ test //')23 def test_it_should_render_a_top_bottom_or_plain_bar_depending_on_the_position_argument(self):24 test_bar1 = r'================================ test ================================'25 test_bar2 = r'//============================== test ==============================\\'26 test_bar3 = r'\\============================== test ==============================//'27 self.assertEqual(bar('test', width=70), test_bar1)28 self.assertEqual(bar('test', width=70, position='top'), test_bar2)29 self.assertEqual(bar('test', width=70, position='bottom'), test_bar3)30 def test_it_should_allow_the_message_to_be_blank(self):31 test_bar1 = r'======================================================================'32 test_bar2 = r'//==================================================================\\'33 test_bar3 = r'\\==================================================================//'34 self.assertEqual(bar(width=70), test_bar1)35 self.assertEqual(bar(width=70, position='top'), test_bar2)...
test_swap.py
Source:test_swap.py
1from utils import bufferPair2def swap(a, b):3 a, b = b, a4class foo():5 def __init__(self, _fields):6 self.fields = _fields7 self.test_bar1 = [233]8 self.test_bar2 = [233, 2333]9 self.b = [233, 233]10 def swap(self):11 self.test_bar1, self.test_bar2 = self.test_bar2, self.test_bar112 def test_swap(self, M):13 M[0] = self.b[0]14if __name__ == "__main__":15 bar1 = foo([[2, 3], [4, 5], [6, 7]])16 # bar2 = foo([[11, 22], [33, 44], [55, 66]])17 # advect_bar = bufferPair(bar1, bar2)18 #19 # advect_foo = []20 # for i in range(3):21 # advect_foo.append(bufferPair(bar1.fields[i], bar2.fields[i]))22 #23 # for i in range(3):24 # advect_foo[i].swap()25 #26 # advect_bar.swap()27 # advect_bar.cur.fields[1][0] = 33328 # advect_foo[1].cur[1] = 44429 # print(advect_bar.cur.fields)30 # print(advect_foo[1].cur)31 a = [2,3]32 bar1.test_swap(a)33 print(a)...
BUILD
Source:BUILD
1package(default_visibility = ["//visibility:public"])2load("@my_deps//:requirements.bzl", "requirement")3load("//:custom_rules.bzl", "py_doctest")4py_library(5 name = "__init__",6 srcs = ["__init__.py"],7)8py_test(9 name = "test_bar1",10 srcs = ["test_bar1.py"],11 size = "medium",12 data = ["test_data/dummy"],13 deps = [14 "//foo:bar1",15 requirement("requests"),16 ],17)18py_test(19 name = "test_bar2",20 srcs = ["test_bar2.py"],21 size = "large",22 deps = ["//foo:bar2"],23)24py_test(25 name = "test_bar3",26 srcs = ["test_bar3.py"],27 size = "small",28 data = glob(["test_data/*.png"]),29)30py_doctest(31 "test_doctest",32 "test_doctest.py",33 deps = [],34)...
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!