How to use test_time method in pytest-benchmark

Best Python code snippet using pytest-benchmark

test_timesince.py

Source: test_timesince.py Github

copy

Full Screen

1# GNU MediaGoblin -- federated, autonomous media hosting2# Copyright (C) 2011, 2012 MediaGoblin contributors. See AUTHORS.3#4# This program is free software: you can redistribute it and/​or modify5# it under the terms of the GNU Affero General Public License as published by6# the Free Software Foundation, either version 3 of the License, or7# (at your option) any later version.8#9# This program is distributed in the hope that it will be useful,10# but WITHOUT ANY WARRANTY; without even the implied warranty of11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the12# GNU Affero General Public License for more details.13#14# You should have received a copy of the GNU Affero General Public License15# along with this program. If not, see <http:/​/​www.gnu.org/​licenses/​>.16from datetime import datetime, timedelta17from mediagoblin.tools.timesince import is_aware, timesince18def test_timesince():19 test_time = datetime.now()20 # it should ignore second and microseconds21 assert timesince(test_time, test_time + timedelta(microseconds=1)) == "0 minutes"22 assert timesince(test_time, test_time + timedelta(seconds=1)) == "0 minutes"23 # test minutes, hours, days, weeks, months and years (singular and plural)24 assert timesince(test_time, test_time + timedelta(minutes=1)) == "1 minute"25 assert timesince(test_time, test_time + timedelta(minutes=2)) == "2 minutes"26 assert timesince(test_time, test_time + timedelta(hours=1)) == "1 hour"27 assert timesince(test_time, test_time + timedelta(hours=2)) == "2 hours"28 assert timesince(test_time, test_time + timedelta(days=1)) == "1 day"29 assert timesince(test_time, test_time + timedelta(days=2)) == "2 days"30 assert timesince(test_time, test_time + timedelta(days=7)) == "1 week"31 assert timesince(test_time, test_time + timedelta(days=14)) == "2 weeks"32 assert timesince(test_time, test_time + timedelta(days=30)) == "1 month"33 assert timesince(test_time, test_time + timedelta(days=60)) == "2 months"34 assert timesince(test_time, test_time + timedelta(days=365)) == "1 year"35 assert timesince(test_time, test_time + timedelta(days=730)) == "2 years"36 # okay now we want to test combinations37 # e.g. 1 hour, 5 days38 assert timesince(test_time, test_time + timedelta(days=5, hours=1)) == "5 days, 1 hour"39 assert timesince(test_time, test_time + timedelta(days=15)) == "2 weeks, 1 day"40 assert timesince(test_time, test_time + timedelta(days=97)) == "3 months, 1 week"...

Full Screen

Full Screen

Blogs

Check out the latest blogs from LambdaTest on this topic:

What is coaching leadership

Coaching is a term that is now being mentioned a lot more in the leadership space. Having grown successful teams I thought that I was well acquainted with this subject.

Webinar: Move Forward With An Effective Test Automation Strategy [Voices of Community]

The key to successful test automation is to focus on tasks that maximize the return on investment (ROI), ensuring that you are automating the right tests and automating them in the right way. This is where test automation strategies come into play.

Are Agile Self-Managing Teams Realistic with Layered Management?

Agile software development stems from a philosophy that being agile means creating and responding to change swiftly. Agile means having the ability to adapt and respond to change without dissolving into chaos. Being Agile involves teamwork built on diverse capabilities, skills, and talents. Team members include both the business and software development sides working together to produce working software that meets or exceeds customer expectations continuously.

A Complete Guide To CSS Grid

Ever since the Internet was invented, web developers have searched for the most efficient ways to display content on web browsers.

Get A Seamless Digital Experience With #LambdaTestYourBusiness????

The holidays are just around the corner, and with Christmas and New Year celebrations coming up, everyone is busy preparing for the festivities! And during this busy time of year, LambdaTest also prepped something special for our beloved developers and testers – #LambdaTestYourBusiness

Automation Testing Tutorials

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.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run pytest-benchmark automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful