How to use get_customization_source method in Slash

Best Python code snippet using slash

test_site_customization.py

Source:test_site_customization.py Github

copy

Full Screen

...31 global _loaded_customizations32 global _customization_index33 _customization_index = 034 _loaded_customizations = []35 def get_customization_source(self):36 global _customization_index37 returned = "import {0}; {0}._apply_customization({1})".format(__name__, _customization_index)38 _customization_index += 139 return returned40 def test_customize_via_local_and_global_slashrc(self):41 self._test_customize_via_local_slashrc(also_use_global=True)42 def test_customize_via_local_slashrc(self):43 self._test_customize_via_local_slashrc(also_use_global=False)44 def _test_customize_via_local_slashrc(self, also_use_global):45 if also_use_global:46 global_slashrc_path = os.path.join(self.get_new_path(), "slashrc")47 self.override_config("run.user_customization_file_path", global_slashrc_path)48 with open(global_slashrc_path, "w") as f:49 f.write(self.get_customization_source())50 new_path = self.get_new_path()51 self.addCleanup(os.chdir, os.path.abspath("."))52 os.chdir(new_path)53 with open(".slashrc", "w") as f:54 f.write(self.get_customization_source())55 self.assert_customization_loaded()56 def test_customize_via_env_var(self):57 os.environ["SLASH_SETTINGS"] = custom_filename = mktemp()58 self.addCleanup(os.environ.pop, "SLASH_SETTINGS")59 with open(custom_filename, "w") as f:60 f.write(self.get_customization_source())61 self.assert_customization_loaded()62 def test_customize_via_url(self):63 url = "http://nonexistent.com/some/path/to/custom/file.py"64 self.forge.replace(requests, "get")65 fake_response = self.forge.create_mock(requests.Response)66 fake_response.raise_for_status().whenever()67 fake_response.content = self.get_customization_source()68 requests.get(url).and_return(fake_response)69 os.environ["SLASH_SETTINGS"] = url70 self.addCleanup(os.environ.pop, "SLASH_SETTINGS")71 self.forge.replay()72 self.assert_customization_loaded()73 def test_customize_via_pkgutil_entry_point(self):74 self.forge.replace(pkg_resources, "iter_entry_points")75 entry_point = self.forge.create_wildcard_mock()76 pkg_resources.iter_entry_points("slash.site.customize").and_return(iter([entry_point]))77 unused = self.get_customization_source() # expect a single customization # pylint: disable=unused-variable78 entry_point.load().and_return(_apply_customization)79 self.forge.replay()80 self.assert_customization_loaded()81 def assert_customization_loaded(self):82 global _loaded_customizations83 global _customization_index84 slash.site.load()...

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