How to use mark_invalid method in hypothesis

Best Python code snippet using hypothesis

launch_process.py

Source:launch_process.py Github

copy

Full Screen

...94 self._next_seq = partial(next, itertools.count(0))95 self._track_process_pid = None96 self._sent_terminated = threading.Event()97 self._rcc_config_location = rcc_config_location98 def mark_invalid(message):99 launch_response.success = False100 launch_response.message = message101 self._valid = False102 robot_yaml = request.arguments.kwargs.get("robot")103 self._terminal = request.arguments.kwargs.get("terminal", TERMINAL_NONE)104 if self._terminal != TERMINAL_NONE:105 # We don't currently support the integrated terminal because we don't106 # have an easy way to get the launched process pid in this way.107 return mark_invalid(108 f"Only 'terminal=none' is supported. Found terminal: {self._terminal}"109 )110 task_name = request.arguments.kwargs.get("task", "")111 args = request.arguments.kwargs.get("args") or []112 if not isinstance(args, list):113 args = [args]114 args = [str(arg) for arg in args]115 env = {}116 request_env = request.arguments.kwargs.get("env")117 if isinstance(request_env, dict) and request_env:118 env.update(request_env)119 env = dict(((as_str(key), as_str(value)) for (key, value) in env.items()))120 self._env = env121 self._run_in_debug_mode = not request.arguments.noDebug122 if self._terminal not in VALID_TERMINAL_OPTIONS:123 return mark_invalid(124 "Invalid terminal option: %s (must be one of: %s)"125 % (self._terminal, VALID_TERMINAL_OPTIONS)126 )127 try:128 if robot_yaml is None:129 return mark_invalid("robot not provided in launch.")130 if not os.path.exists(robot_yaml):131 return mark_invalid("File: %s does not exist." % (robot_yaml,))132 except:133 log.exception("Error")134 return mark_invalid("Error checking if robot (%s) exists." % (robot_yaml,))135 self._cwd = os.path.dirname(robot_yaml)136 try:137 if self._cwd is not None:138 if not os.path.exists(self._cwd):139 return mark_invalid(140 "cwd specified does not exist: %s" % (self._cwd,)141 )142 except:143 log.exception("Error")144 return mark_invalid("Error checking if cwd (%s) exists." % (self._cwd,))145 if get_log_level() > 1:146 log.debug("Run in debug mode: %s\n" % (self._run_in_debug_mode,))147 try:148 config = Config()149 config_provider = _DefaultConfigurationProvider(config)150 rcc = Rcc(config_provider=config_provider)151 rcc_executable = rcc.get_rcc_location()152 if not os.path.exists(rcc_executable):153 return mark_invalid(f"Expected: {rcc_executable} to exist.")154 except:155 log.exception("Error")156 return mark_invalid("Error getting rcc executable location.")157 else:158 task_args = []159 if task_name:160 task_args.append("--task")161 task_args.append(task_name)162 cmdline = (163 [rcc_executable, "task", "run", "--robot", robot_yaml]164 + task_args165 + args166 )167 if self._rcc_config_location:168 cmdline.append("--config")169 cmdline.append(self._rcc_config_location)170 env_json_path = Path(robot_yaml).parent / "devdata" / "env.json"...

Full Screen

Full Screen

validator.py

Source:validator.py Github

copy

Full Screen

...15 self.validate_hgt(self, passport['hgt'])16 self.validate_hcl(self, passport['hcl'])17 self.validate_ecl(self, passport['ecl'])18 self.validate_pid(self, passport['pid'])19 def mark_invalid(self, key):20 self.valid = False21 self.report.append(key)22 def validate_byr(self, byr):23 """24 four digits; at least 1920 and at most 200225 """26 if not self.valid:27 return28 if int(byr) not in range(1920, 2002):29 self.mark_invalid(self, 'byr')30 def validate_iyr(self, iyr):31 """32 four digits; at least 2010 and at most 202033 """34 if not self.valid:35 return36 if int(iyr) not in range(2010, 2021):37 self.mark_invalid(self, 'iyr')38 def validate_eyr(self, eyr):39 """40 four digits; at least 2020 and at most 203041 """42 if not self.valid:43 return44 if int(eyr) not in range(2020, 2031):45 self.mark_invalid(self, 'eyr')46 def validate_hgt(self, hgt):47 """48 a number followed by either cm or in:49 If cm, the number must be at least 150 and at most 193.50 If in, the number must be at least 59 and at most 76.51 """52 unit = hgt[-2:]53 measurement = hgt[:-2]54 if not self.valid:55 return56 if not measurement:57 self.mark_invalid(self, 'hgt')58 if unit == 'cm' and int(measurement) not in range(150, 194):59 self.mark_invalid(self, 'hgt')60 elif unit == 'in' and int(measurement) not in range(59, 77):61 self.mark_invalid(self, 'hgt')62 def validate_hcl(self, hcl):63 """64 a # followed by exactly six characters 0-9 or a-f65 """66 if not self.valid:67 return68 if not re.fullmatch("^#[0-9a-fA-F]{6}", hcl):69 self.mark_invalid(self, 'hcl')70 def validate_ecl(self, ecl):71 """72 exactly one of: amb blu brn gry grn hzl oth73 """74 if not self.valid:75 return76 if ecl not in ['amb', 'blu', 'brn', 'gry', 'grn', 'hzl', 'oth']:77 self.mark_invalid(self, 'ecl')78 def validate_pid(self, pid):79 """80 a nine-digit number, including leading zeroes.81 """82 if not self.valid:83 return84 if not re.fullmatch("^[0-9]{9}", pid):...

Full Screen

Full Screen

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 hypothesis 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