Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_user_not_in_sock_group(self):
group = self._get_non_member_group()
instance = self._new_instance(
{"sock_group": group.gr_name}, expect_success=False
)
with self.assertRaises(pywatchman.SocketConnectError) as ctx:
instance.start()
self.assertEqual(ctx.exception.sockpath, instance.getSockPath())
wanted = "setting up group '%s' failed" % group.gr_name
self.assertWaitFor(
lambda: wanted in instance.getCLILogContents(),
get_debug_output=lambda: instance.getCLILogContents(),
)
if self.debug_watchman:
print("Watchman instance PID: " + str(self.proc.pid))
if pywatchman.compat.PYTHON3:
user_input = input
else:
user_input = raw_input # noqa:F821
user_input("Press Enter to continue...")
# wait for it to come up
deadline = time.time() + self.start_timeout
while time.time() < deadline:
try:
client = pywatchman.client(sockpath=self.sock_file)
self.pid = client.query("get-pid")["pid"]
break
except pywatchman.SocketConnectError:
t, val, tb = sys.exc_info()
time.sleep(0.1)
finally:
client.close()
if self.pid is None:
# self.proc didn't come up: wait for it to die
self.stop()
pywatchman.compat.reraise(t, val, tb)
def test_too_open_user_dir(self):
instance = self._new_instance({}, expect_success=False)
os.makedirs(instance.user_dir)
os.chmod(instance.user_dir, 0o777)
with self.assertRaises(pywatchman.SocketConnectError) as ctx:
instance.start()
self.assertEqual(ctx.exception.sockpath, instance.getSockPath())
wanted = "the permissions on %s allow others to write to it" % (
instance.user_dir
)
self.assertWaitFor(
lambda: wanted in instance.getCLILogContents(),
get_debug_output=lambda: instance.getCLILogContents(),
)