Best Python code snippet using pandera_python
recompile_requirements.py
Source: recompile_requirements.py
...152 def __init__(self, name: str, base_path: pathlib.Path) -> None:153 self.name = name154 self.old = None155 self.new = None156 self.base = extract_requirement_name(base_path)157 if CHANGELOG_URLS.get(name):158 self.url = CHANGELOG_URLS[name]159 self.link = '[{}]({})'.format(self.name, self.url)160 else:161 self.url = '(no changelog)'162 self.link = self.name163 def __lt__(self, other):164 return (self.base, self.name.lower()) < (other.base, other.name.lower())165 def __str__(self):166 prefix = f"- [{self.base}] {self.name}"167 suffix = f" {self.url}"168 if self.old is None:169 return f"{prefix} new: {self.new} {suffix}"170 elif self.new is None:171 return f"{prefix} removed: {self.old} {suffix}"172 else:173 return f"{prefix} {self.old} -> {self.new} {suffix}"174 def table_str(self):175 """Generate a markdown table."""176 if self.old is None:177 return f'| {self.base} | {self.link} | -- | {self.new} |'178 elif self.new is None:179 return f'| {self.base} | {self.link} | {self.old} | -- |'180 else:181 return f'| {self.base} | {self.link} | {self.old} | {self.new} |'182def _get_changed_files():183 """Get a list of changed files via git."""184 changed_files = set()185 filenames = git_diff('--name-only')186 for filename in filenames:187 requirement_name = extract_requirement_name(pathlib.Path(filename))188 changed_files.add(requirement_name)189 return sorted(changed_files)190def extract_requirement_name(path: pathlib.Path) -> str:191 """Get a requirement name from a file path.192 e.g. "pylint" from "misc/requirements/requirements-pylint.txt"193 """194 if path == pathlib.Path("requirements.txt"):195 return "qutebrowser"196 prefix = "requirements-"197 assert path.suffix == ".txt", path198 assert path.stem.startswith(prefix), path199 return path.stem[len(prefix):]200def parse_versioned_line(line):201 """Parse a requirements.txt line into name/version."""202 if line[0] == '#': # ignored dependency203 line = line[1:].strip()204 # Strip comments and pip environment markers...
noxfile.py
Source: noxfile.py
...97CONDA_ARGS = [98 "--channel=conda-forge",99 "--update-specs",100]101def extract_requirement_name(spec: str) -> str:102 """103 Extract name of requirement from dependency string.104 """105 # Assume name is everything up to the first invalid character106 match = re.match(r"^[A-Za-z0-9-_]*", spec.strip())107 if not match:108 raise ValueError(f"Cannot parse requirement {spec!r}")109 return match[0]110def conda_install(session: Session, *args):111 """Use mamba to install conda dependencies."""112 run_args = [113 "install",114 "--yes",115 *CONDA_ARGS,116 "--prefix",117 session.virtualenv.location, # type: ignore118 *args,119 ]120 # By default, all dependencies are re-installed from scratch with each121 # session. Specifying external=True allows access to cached packages, which122 # decreases runtime of the test sessions.123 try:124 session.run(125 *["mamba", *run_args],126 external=True,127 )128 # pylint: disable=broad-except129 except Exception:130 session.run(131 *["conda", *run_args],132 external=True,133 )134def install(session: Session, *args: str):135 """Install dependencies in the appropriate virtual environment136 (conda or virtualenv) and return the type of the environmment."""137 if isinstance(session.virtualenv, nox.virtualenv.CondaEnv):138 print("using conda installer")139 conda_install(session, *args)140 else:141 print("using pip installer")142 session.install(*args)143def install_from_requirements(session: Session, *packages: str) -> None:144 """145 Install dependencies, respecting the version specified in requirements.146 """147 for package in packages:148 try:149 specs = REQUIRES["all"][package]150 except KeyError:151 raise ValueError(152 f"{package} cannot be found in {REQUIREMENT_PATH}."153 ) from None154 install(session, specs)155def install_extras(156 session: Session,157 extra: str = "core",158 force_pip: bool = False,159 pandas: str = "latest",160 pandas_stubs: bool = True,161) -> None:162 """Install dependencies."""163 if isinstance(session.virtualenv, nox.virtualenv.PassthroughEnv):164 # skip this step if there's no virtual environment specified165 session.run("pip", "install", "-e", ".", "--no-deps")166 return167 specs, pip_specs = [], []168 pandas_version = "" if pandas == "latest" else f"=={pandas}"169 for spec in REQUIRES[extra].values():170 req_name = extract_requirement_name(spec)171 if req_name == "pandas-stubs" and not pandas_stubs:172 # this is a temporary measure until all pandas-related mypy errors173 # are addressed174 continue175 req = Requirement(spec) # type: ignore176 # this is needed until ray is supported on python 3.10177 # pylint: disable=line-too-long178 if req.name in {"ray", "geopandas"} and session.python == "3.10": # type: ignore[attr-defined] # noqa179 continue180 if req.name in ALWAYS_USE_PIP: # type: ignore[attr-defined]181 pip_specs.append(spec)182 elif req_name == "pandas" and pandas != "latest":183 specs.append(f"pandas~={pandas}")184 else:...
Check out the latest blogs from LambdaTest on this topic:
I routinely come across test strategy documents when working with customers. They are lengthy—100 pages or more—and packed with monotonous text that is routinely reused from one project to another. Yawn once more— the test halt and resume circumstances, the defect management procedure, entrance and exit criteria, unnecessary generic risks, and in fact, one often-used model replicates the requirements of textbook testing, from stress to systems integration.
When I started writing tests with Cypress, I was always going to use the user interface to interact and change the application’s state when running tests.
Pair testing can help you complete your testing tasks faster and with higher quality. But who can do pair testing, and when should it be done? And what form of pair testing is best for your circumstance? Check out this blog for more information on how to conduct pair testing to optimize its benefits.
People love to watch, read and interact with quality content — especially video content. Whether it is sports, news, TV shows, or videos captured on smartphones, people crave digital content. The emergence of OTT platforms has already shaped the way people consume content. Viewers can now enjoy their favorite shows whenever they want rather than at pre-set times. Thus, the OTT platform’s concept of viewing anything, anytime, anywhere has hit the right chord.
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.
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!!