Exemplo n.º 1
0
    def test_register_unregister_location_env(self):
        user_environments_txt_file = get_user_environments_txt_file()
        if (not os.path.exists(user_environments_txt_file)
                or user_environments_txt_file == os.devnull):
            pytest.skip('user environments.txt file {} does not exist'.format(
                user_environments_txt_file))

        gascon_location = join(self.prefix, 'gascon')
        touch(join(gascon_location, PREFIX_MAGIC_FILE), mkdir=True)
        assert gascon_location not in list_all_known_prefixes()

        touch(user_environments_txt_file, mkdir=True, sudo_safe=True)
        register_env(gascon_location)
        assert gascon_location in yield_lines(user_environments_txt_file)
        assert len(
            tuple(x for x in yield_lines(user_environments_txt_file)
                  if paths_equal(gascon_location, x))) == 1

        register_env(gascon_location)  # should be completely idempotent
        assert len(
            tuple(x for x in yield_lines(user_environments_txt_file)
                  if x == gascon_location)) == 1

        unregister_env(gascon_location)
        assert gascon_location not in list_all_known_prefixes()
        unregister_env(gascon_location)  # should be idempotent
        assert gascon_location not in list_all_known_prefixes()
Exemplo n.º 2
0
    def test_register_unregister_location_env(self):
        gascon_location = join(self.prefix, 'gascon')
        touch(join(gascon_location, PREFIX_MAGIC_FILE), mkdir=True)
        assert gascon_location not in list_all_known_prefixes()

        touch(USER_ENVIRONMENTS_TXT_FILE, mkdir=True, sudo_safe=True)
        register_env(gascon_location)
        assert gascon_location in yield_lines(USER_ENVIRONMENTS_TXT_FILE)
        assert len(
            tuple(x for x in yield_lines(USER_ENVIRONMENTS_TXT_FILE)
                  if paths_equal(gascon_location, x))) == 1

        register_env(gascon_location)  # should be completely idempotent
        assert len(
            tuple(x for x in yield_lines(USER_ENVIRONMENTS_TXT_FILE)
                  if x == gascon_location)) == 1

        unregister_env(gascon_location)
        assert gascon_location not in list_all_known_prefixes()
        unregister_env(gascon_location)  # should be idempotent
        assert gascon_location not in list_all_known_prefixes()
Exemplo n.º 3
0
    def test_register_unregister_location_env(self):
        user_environments_txt_file = get_user_environments_txt_file()
        if (not os.path.exists(user_environments_txt_file)
            or user_environments_txt_file == os.devnull):
            pytest.skip('user environments.txt file {} does not exist'.format(user_environments_txt_file))

        gascon_location = join(self.prefix, 'gascon')
        touch(join(gascon_location, PREFIX_MAGIC_FILE), mkdir=True)
        assert gascon_location not in list_all_known_prefixes()

        touch(user_environments_txt_file, mkdir=True, sudo_safe=True)
        register_env(gascon_location)
        assert gascon_location in yield_lines(user_environments_txt_file)
        assert len(tuple(x for x in yield_lines(user_environments_txt_file) if paths_equal(gascon_location, x))) == 1

        register_env(gascon_location)  # should be completely idempotent
        assert len(tuple(x for x in yield_lines(user_environments_txt_file) if x == gascon_location)) == 1

        unregister_env(gascon_location)
        assert gascon_location not in list_all_known_prefixes()
        unregister_env(gascon_location)  # should be idempotent
        assert gascon_location not in list_all_known_prefixes()