How to use test_abs_path method in molecule

Best Python code snippet using molecule_python

test_virtualenv.py

Source: test_virtualenv.py Github

copy

Full Screen

1import virtualenv2import optparse3import os4import shutil5import sys6import tempfile7import pytest8import platform # noqa9from mock import patch, Mock10def test_version():11 """Should have a version string"""12 assert virtualenv.virtualenv_version, "Should have version"13@patch('os.path.exists')14def test_resolve_interpreter_with_absolute_path(mock_exists):15 """Should return absolute path if given and exists"""16 mock_exists.return_value = True17 virtualenv.is_executable = Mock(return_value=True)18 test_abs_path = os.path.abspath("/​usr/​bin/​python53")19 exe = virtualenv.resolve_interpreter(test_abs_path)20 assert exe == test_abs_path, "Absolute path should return as is"21 mock_exists.assert_called_with(test_abs_path)22 virtualenv.is_executable.assert_called_with(test_abs_path)23@patch('os.path.exists')24def test_resolve_interpreter_with_nonexistent_interpreter(mock_exists):25 """Should SystemExit with an nonexistent python interpreter path"""26 mock_exists.return_value = False27 with pytest.raises(SystemExit):28 virtualenv.resolve_interpreter("/​usr/​bin/​python53")29 mock_exists.assert_called_with("/​usr/​bin/​python53")30@patch('os.path.exists')31def test_resolve_interpreter_with_invalid_interpreter(mock_exists):32 """Should exit when with absolute path if not exists"""33 mock_exists.return_value = True34 virtualenv.is_executable = Mock(return_value=False)35 invalid = os.path.abspath("/​usr/​bin/​pyt_hon53")36 with pytest.raises(SystemExit):37 virtualenv.resolve_interpreter(invalid)38 mock_exists.assert_called_with(invalid)39 virtualenv.is_executable.assert_called_with(invalid)40def test_activate_after_future_statements():41 """Should insert activation line after last future statement"""42 script = [43 '#!/​usr/​bin/​env python',44 'from __future__ import with_statement',45 'from __future__ import print_function',46 'print("Hello, world!")'47 ]48 assert virtualenv.relative_script(script) == [49 '#!/​usr/​bin/​env python',50 'from __future__ import with_statement',51 'from __future__ import print_function',52 '',53 "import os; activate_this=os.path.join(os.path.dirname(os.path.realpath(__file__)), 'activate_this.py'); exec(compile(open(activate_this).read(), activate_this, 'exec'), dict(__file__=activate_this)); del os, activate_this",54 '',55 'print("Hello, world!")'56 ]57def test_cop_update_defaults_with_store_false():58 """store_false options need reverted logic"""59 class MyConfigOptionParser(virtualenv.ConfigOptionParser):60 def __init__(self, *args, **kwargs):61 self.config = virtualenv.ConfigParser.RawConfigParser()62 self.files = []63 optparse.OptionParser.__init__(self, *args, **kwargs)64 def get_environ_vars(self, prefix='VIRTUALENV_'):65 yield ("no_site_packages", "1")66 cop = MyConfigOptionParser()67 cop.add_option(68 '--no-site-packages',69 dest='system_site_packages',70 action='store_false',71 help="Don't give access to the global site-packages dir to the "72 "virtual environment (default)")73 defaults = {}74 cop.update_defaults(defaults)75 assert defaults == {'system_site_packages': 0}76def test_install_python_bin():77 """Should create the right python executables and links"""78 tmp_virtualenv = tempfile.mkdtemp()79 try:80 home_dir, lib_dir, inc_dir, bin_dir = \81 virtualenv.path_locations(tmp_virtualenv)82 virtualenv.install_python(home_dir, lib_dir, inc_dir, bin_dir, False,83 False)84 if virtualenv.is_win:85 required_executables = [ 'python.exe', 'pythonw.exe']86 else:87 py_exe_no_version = 'python'88 py_exe_version_major = 'python%s' % sys.version_info[0]89 py_exe_version_major_minor = 'python%s.%s' % (90 sys.version_info[0], sys.version_info[1])91 required_executables = [ py_exe_no_version, py_exe_version_major,92 py_exe_version_major_minor ]93 for pth in required_executables:94 assert os.path.exists(os.path.join(bin_dir, pth)), ("%s should "95 "exist in bin_dir" % pth)96 finally:97 shutil.rmtree(tmp_virtualenv)98@pytest.mark.skipif("platform.python_implementation() == 'PyPy'")99def test_always_copy_option():100 """Should be no symlinks in directory tree"""101 tmp_virtualenv = tempfile.mkdtemp()102 ve_path = os.path.join(tmp_virtualenv, 'venv')103 try:104 virtualenv.create_environment(ve_path, symlink=False)105 for root, dirs, files in os.walk(tmp_virtualenv):106 for f in files + dirs:107 full_name = os.path.join(root, f)108 assert not os.path.islink(full_name), "%s should not be a" \109 " symlink (to %s)" % (full_name, os.readlink(full_name))110 finally:...

Full Screen

Full Screen

Blogs

Check out the latest blogs from LambdaTest on this topic:

LIVE With Automation Testing For OTT Streaming Devices ????

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.

How To Refresh Page Using Selenium C# [Complete Tutorial]

When working on web automation with Selenium, I encountered scenarios where I needed to refresh pages from time to time. When does this happen? One scenario is that I needed to refresh the page to check that the data I expected to see was still available even after refreshing. Another possibility is to clear form data without going through each input individually.

Two-phase Model-based Testing

Most test automation tools just do test execution automation. Without test design involved in the whole test automation process, the test cases remain ad hoc and detect only simple bugs. This solution is just automation without real testing. In addition, test execution automation is very inefficient.

Stop Losing Money. Invest in Software Testing

I was once asked at a testing summit, “How do you manage a QA team using scrum?” After some consideration, I realized it would make a good article, so here I am. Understand that the idea behind developing software in a scrum environment is for development teams to self-organize.

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