Best Python code snippet using pytest-django_python
test_AxisItem.py
Source: test_AxisItem.py
1import pyqtgraph as pg2app = pg.mkQApp()3def test_AxisItem_stopAxisAtTick(monkeypatch):4 def test_bottom(p, axisSpec, tickSpecs, textSpecs):5 assert view.mapToView(axisSpec[1]).x() == 0.256 assert view.mapToView(axisSpec[2]).x() == 0.757 def test_left(p, axisSpec, tickSpecs, textSpecs):8 assert view.mapToView(axisSpec[1]).y() == 0.8759 assert view.mapToView(axisSpec[2]).y() == 0.12510 plot = pg.PlotWidget()11 view = plot.plotItem.getViewBox()12 bottom = plot.getAxis("bottom")13 bottom.setRange(0, 1)14 bticks = [(0.25, "a"), (0.6, "b"), (0.75, "c")]15 bottom.setTicks([bticks, bticks])16 bottom.setStyle(stopAxisAtTick=(True, True))17 monkeypatch.setattr(bottom, "drawPicture", test_bottom)18 left = plot.getAxis("left")19 lticks = [(0.125, "a"), (0.55, "b"), (0.875, "c")]20 left.setTicks([lticks, lticks])21 left.setRange(0, 1)22 left.setStyle(stopAxisAtTick=(True, True))23 monkeypatch.setattr(left, "drawPicture", test_left)24 plot.show()25 app.processEvents()26 plot.close()27def test_AxisItem_viewUnlink():28 plot = pg.PlotWidget()29 view = plot.plotItem.getViewBox()30 axis = plot.getAxis("bottom")31 assert axis.linkedView() == view32 axis.unlinkFromView()33 assert axis.linkedView() is None34class FakeSignal:35 def __init__(self):36 self.calls = []37 def connect(self, *args, **kwargs):38 self.calls.append('connect')39 def disconnect(self, *args, **kwargs):40 self.calls.append('disconnect')41class FakeView:42 def __init__(self):43 self.sigYRangeChanged = FakeSignal()44 self.sigXRangeChanged = FakeSignal()45 self.sigResized = FakeSignal()46def test_AxisItem_bottomRelink():47 axis = pg.AxisItem('bottom')48 fake_view = FakeView()49 axis.linkToView(fake_view)50 assert axis.linkedView() == fake_view51 assert fake_view.sigYRangeChanged.calls == []52 assert fake_view.sigXRangeChanged.calls == ['connect']53 assert fake_view.sigResized.calls == ['connect']54 axis.unlinkFromView()55 assert fake_view.sigYRangeChanged.calls == []56 assert fake_view.sigXRangeChanged.calls == ['connect', 'disconnect']57 assert fake_view.sigResized.calls == ['connect', 'disconnect']58def test_AxisItem_leftRelink():59 axis = pg.AxisItem('left')60 fake_view = FakeView()61 axis.linkToView(fake_view)62 assert axis.linkedView() == fake_view63 assert fake_view.sigYRangeChanged.calls == ['connect']64 assert fake_view.sigXRangeChanged.calls == []65 assert fake_view.sigResized.calls == ['connect']66 axis.unlinkFromView()67 assert fake_view.sigYRangeChanged.calls == ['connect', 'disconnect']68 assert fake_view.sigXRangeChanged.calls == []...
test_urls.py
Source: test_urls.py
...16def test_urls_cache_is_cleared(testdir):17 testdir.makepyfile(18 myurls="""19 from django.conf.urls import url20 def fake_view(request):21 pass22 urlpatterns = [url(r'first/$', fake_view, name='first')]23 """24 )25 testdir.makepyfile(26 """27 try:28 from django.urls import reverse, NoReverseMatch29 except ImportError: # Django < 2.030 from django.core.urlresolvers import reverse, NoReverseMatch31 import pytest32 @pytest.mark.urls('myurls')33 def test_something():34 reverse('first')35 def test_something_else():36 with pytest.raises(NoReverseMatch):37 reverse('first')38 """39 )40 result = testdir.runpytest_subprocess()41 assert result.ret == 042def test_urls_cache_is_cleared_and_new_urls_can_be_assigned(testdir):43 testdir.makepyfile(44 myurls="""45 from django.conf.urls import url46 def fake_view(request):47 pass48 urlpatterns = [url(r'first/$', fake_view, name='first')]49 """50 )51 testdir.makepyfile(52 myurls2="""53 from django.conf.urls import url54 def fake_view(request):55 pass56 urlpatterns = [url(r'second/$', fake_view, name='second')]57 """58 )59 testdir.makepyfile(60 """61 try:62 from django.urls import reverse, NoReverseMatch63 except ImportError: # Django < 2.064 from django.core.urlresolvers import reverse, NoReverseMatch65 import pytest66 @pytest.mark.urls('myurls')67 def test_something():68 reverse('first')...
Check out the latest blogs from LambdaTest on this topic:
Hey Folks! Welcome back to the latest edition of LambdaTest’s product updates. Since programmer’s day is just around the corner, our incredible team of developers came up with several new features and enhancements to add some zing to your workflow. We at LambdaTest are continuously upgrading the features on our platform to make lives easy for the QA community. We are releasing new functionality almost every week.
Technical debt was originally defined as code restructuring, but in today’s fast-paced software delivery environment, it has evolved. Technical debt may be anything that the software development team puts off for later, such as ineffective code, unfixed defects, lacking unit tests, excessive manual tests, or missing automated tests. And, like financial debt, it is challenging to pay back.
Smartphones have changed the way humans interact with technology. Be it travel, fitness, lifestyle, video games, or even services, it’s all just a few touches away (quite literally so). We only need to look at the growing throngs of smartphone or tablet users vs. desktop users to grasp this reality.
If you are a web tester then somewhere down the road you will have to come across Selenium, an open-source test automation framework that has been on boom ever since its launch in 2004.
The web paradigm has changed considerably over the last few years. Web 2.0, a term coined way back in 1999, was one of the pivotal moments in the history of the Internet. UGC (User Generated Content), ease of use, and interoperability for the end-users were the key pillars of Web 2.0. Consumers who were only consuming content up till now started creating different forms of content (e.g., text, audio, video, etc.).
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!!