How to use the ptr.MACOSX function in ptr

To help you get started, we’ve selected a few ptr examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github facebookincubator / ptr / ptr_tests.py View on Github external
def test_mac_osx_slash_private(self) -> None:
        macosx = ptr.MACOSX
        non_private_path_str = "/var/tmp"
        private_path_str = f"/private{non_private_path_str}"
        site_packages_path = Path("/var/tmp/venv/lib/site-packages/")
        try:
            ptr.MACOSX = False
            self.assertEqual(
                Path(private_path_str),
                ptr._max_osx_private_handle(private_path_str, site_packages_path),
            )

            ptr.MACOSX = True
            self.assertEqual(
                Path(non_private_path_str),
                ptr._max_osx_private_handle(private_path_str, site_packages_path),
            )

            site_packages_path = Path("/private/var/tmp/venv/lib/site-packages/")
            self.assertEqual(
                Path(private_path_str),
                ptr._max_osx_private_handle(private_path_str, site_packages_path),
            )
        finally:
            # Ensure we also restore if we're MACOSX or not
            ptr.MACOSX = macosx
github facebookincubator / ptr / ptr_tests.py View on Github external
def test_mac_osx_slash_private(self) -> None:
        macosx = ptr.MACOSX
        non_private_path_str = "/var/tmp"
        private_path_str = f"/private{non_private_path_str}"
        site_packages_path = Path("/var/tmp/venv/lib/site-packages/")
        try:
            ptr.MACOSX = False
            self.assertEqual(
                Path(private_path_str),
                ptr._max_osx_private_handle(private_path_str, site_packages_path),
            )

            ptr.MACOSX = True
            self.assertEqual(
                Path(non_private_path_str),
                ptr._max_osx_private_handle(private_path_str, site_packages_path),
            )

            site_packages_path = Path("/private/var/tmp/venv/lib/site-packages/")
            self.assertEqual(
                Path(private_path_str),
                ptr._max_osx_private_handle(private_path_str, site_packages_path),
            )
github facebookincubator / ptr / ptr_tests.py View on Github external
)

            ptr.MACOSX = True
            self.assertEqual(
                Path(non_private_path_str),
                ptr._max_osx_private_handle(private_path_str, site_packages_path),
            )

            site_packages_path = Path("/private/var/tmp/venv/lib/site-packages/")
            self.assertEqual(
                Path(private_path_str),
                ptr._max_osx_private_handle(private_path_str, site_packages_path),
            )
        finally:
            # Ensure we also restore if we're MACOSX or not
            ptr.MACOSX = macosx
github facebookincubator / ptr / ptr_tests.py View on Github external
def test_gen_output(self) -> None:
        test_cmd = ("echo.exe", "''") if ptr.WINDOWS else ("/bin/echo",)

        stdout, stderr = self.loop.run_until_complete(ptr._gen_check_output(test_cmd))
        self.assertTrue(b"\n" in stdout)
        self.assertEqual(stderr, None)

        if ptr.WINDOWS:
            return

        # TODO: Test this on Windows and ensure we capture failures corerctly
        with self.assertRaises(CalledProcessError):
            if ptr.MACOSX:
                false = "/usr/bin/false"
            else:
                false = "/bin/false"

            self.loop.run_until_complete(ptr._gen_check_output((false,)))
github facebookincubator / ptr / ptr_tests.py View on Github external
def test_mac_osx_slash_private(self) -> None:
        macosx = ptr.MACOSX
        non_private_path_str = "/var/tmp"
        private_path_str = f"/private{non_private_path_str}"
        site_packages_path = Path("/var/tmp/venv/lib/site-packages/")
        try:
            ptr.MACOSX = False
            self.assertEqual(
                Path(private_path_str),
                ptr._max_osx_private_handle(private_path_str, site_packages_path),
            )

            ptr.MACOSX = True
            self.assertEqual(
                Path(non_private_path_str),
                ptr._max_osx_private_handle(private_path_str, site_packages_path),
            )