Best Python code snippet using pytest-cov
engine.py
Source: engine.py
...23 setattr(obj, attr, copy.copy(backup))24 yield25 finally:26 setattr(obj, attr, backup)27def _ensure_topdir(meth):28 @functools.wraps(meth)29 def ensure_topdir_wrapper(self, *args, **kwargs):30 try:31 original_cwd = os.getcwd()32 except OSError:33 # Looks like it's gone, this is non-ideal because a side-effect will34 # be introduced in the tests here but we can't do anything about it.35 original_cwd = None36 os.chdir(self.topdir)37 try:38 return meth(self, *args, **kwargs)39 finally:40 if original_cwd is not None:41 os.chdir(original_cwd)42 return ensure_topdir_wrapper43class CovController(object):44 """Base class for different plugin implementations."""45 def __init__(self, cov_source, cov_report, cov_config, cov_append, cov_branch, config=None, nodeid=None):46 """Get some common config used by multiple derived classes."""47 self.cov_source = cov_source48 self.cov_report = cov_report49 self.cov_config = cov_config50 self.cov_append = cov_append51 self.cov_branch = cov_branch52 self.config = config53 self.nodeid = nodeid54 self.cov = None55 self.combining_cov = None56 self.data_file = None57 self.node_descs = set()58 self.failed_workers = []59 self.topdir = os.getcwd()60 self.is_collocated = None61 @contextlib.contextmanager62 def ensure_topdir(self):63 original_cwd = os.getcwd()64 os.chdir(self.topdir)65 yield66 os.chdir(original_cwd)67 @_ensure_topdir68 def pause(self):69 self.cov.stop()70 self.unset_env()71 @_ensure_topdir72 def resume(self):73 self.cov.start()74 self.set_env()75 @_ensure_topdir76 def set_env(self):...
Check out the latest blogs from LambdaTest on this topic:
Have you ever visited a website that only has plain text and images? Most probably, no. It’s because such websites do not exist now. But there was a time when websites only had plain text and images with almost no styling. For the longest time, websites did not focus on user experience. For instance, this is how eBay’s homepage looked in 1999.
In today’s world, an organization’s most valuable resource is its customers. However, acquiring new customers in an increasingly competitive marketplace can be challenging while maintaining a strong bond with existing clients. Implementing a customer relationship management (CRM) system will allow your organization to keep track of important customer information. This will enable you to market your services and products to these customers better.
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
In 2007, Steve Jobs launched the first iPhone, which revolutionized the world. But because of that, many businesses dealt with the problem of changing the layout of websites from desktop to mobile by delivering completely different mobile-compatible websites under the subdomain of ‘m’ (e.g., https://m.facebook.com). And we were all trying to figure out how to work in this new world of contending with mobile and desktop screen sizes.
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!!