How to use run_unit_tests method in SeleniumLibrary

Best Python code snippet using SeleniumLibrary

Run SeleniumLibrary automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

testCommands.py

Source: testCommands.py Github

copy
1# -*- coding: utf-8 -*-
2#@+leo-ver=5-thin
3#@+node:ekr.20210907103011.1: * @file ../commands/testCommands.py
4#@@first
5"""Unit tests commands"""
6
7import os
8import time
9from leo.core import leoGlobals as g
10
11#@+others
12#@+node:ekr.20210907103024.2: ** coverage test commands...
13#@+node:ekr.20210907103024.3: *3* cover-all
14#@@nowrap
15@g.command('cover-all')
16def cover_all(event=None):
17    """Run all coverage tests in leo.unittests."""
18    leo_editor_dir = os.path.join(g.app.loadDir, '..', '..')
19    os.chdir(leo_editor_dir)
20    if 1:
21        # This is usually best:
22        # - It creates a full report in index.html.
23        # - It runs all unit tests in the leo.unittests directory.
24        command = r"python -m pytest --cov-report html --cov-report term-missing --cov"
25        g.execute_shell_commands(command, trace=False)
26    else:
27        # This runs only the listed files. index.html describes only the last file.
28        table = (
29            ('leo.core.leoApp', 'leo/unittests/core/test_leoApp.py'),
30            ('leo.core.leoAst', 'leo/unittests/core/test_leoAst.py'),
31            ('leo.core.leoAtFile', 'leo/unittests/core/test_leoAtFile.py'),
32            ('leo.core.leoBridge', 'leo/unittests/core/test_leoBridge.py'),
33            ('leo.commands.checkerCommands', 'leo/unittests/commands/test_checkerCommands.py'),
34            ('leo.core.leoColorizer', 'leo/unittests/core/test_leoColorizer.py'),
35            ('leo.core.leoCommands', 'leo/unittests/core/test_leoCommands.py'),
36            ('leo.core.leoConfig', 'leo/unittests/core/test_leoConfig.py'),
37            ('leo.commands.convertCommands', 'leo/unittests/commands/test_convertCommands.py'),
38            ('leo.commands.editCommands', 'leo/unittests/commands/test_editCommands.py'),
39            ('leo.core.leoFileCommands', 'leo/unittests/core/test_leoFileCommands.py'),
40            ('leo.core.leoFind', 'leo/unittests/core/test_leoFind.py'),
41            ('leo.core.leoFrame', 'leo/unittests/core/test_leoFrame.py'),
42            ('leo.core.leoGlobals', 'leo/unittests/core/test_leoGlobals.py'),
43            ('leo.core.leoImport', 'leo/unittests/core/test_leoImport.py'),
44            ('leo.core.leoKeys', 'leo/unittests/core/test_leoKeys.py'),
45            ('leo.core.leoserver', 'leo/unittests/core/test_leoserver.py'),
46            ('leo.core.leoNodes', 'leo/unittests/core/test_leoNodes.py'),
47            ('leo.core.leoPersistence', 'leo/unittests/core/test_leoPersistence.py'),
48            ('leo.core.leoRst', 'leo/unittests/core/test_leoRst.py'),
49            ('leo.core.leoShadow', 'leo/unittests/core/test_leoShadow.py'),
50            ('leo.core.leoUndo', 'leo/unittests/core/test_leoUndo.py'),
51            ('leo.core.leoVim', 'leo/unittests/core/test_leoVim.py'),
52        )
53        for module, filename in table:
54            g.run_coverage_tests(module, filename)
55#@+node:ekr.20210911072153.3: *3* cover-app
56@g.command('cover-app')
57def cover_app(event=None):
58    """Run all coverage tests for leoApp.py."""
59    g.run_coverage_tests('leo.core.leoApp', 'leo/unittests/core/test_leoApp.py')
60#@+node:ekr.20210907103024.4: *3* cover-ast
61@g.command('cover-ast')
62def cover_ast(event=None):
63    """Run all coverage tests for leoAst.py."""
64    g.run_coverage_tests('leo.core.leoAst', 'leo/unittests/core/test_leoAst.py')
65#@+node:ekr.20210907103024.5: *3* cover-atfile
66@g.command('cover-atfile')
67def cover_atfile(event=None):
68    """Run all coverage tests for leoAtFile.py."""
69    g.run_coverage_tests('leo.core.leoAtFile', 'leo/unittests/core/test_leoAtFile.py')
70#@+node:ekr.20210911072153.6: *3* cover-bridge
71@g.command('cover-bridge')
72def cover_bridge(event=None):
73    """Run all coverage tests for leoBridge.py."""
74    g.run_coverage_tests('leo.core.leoBridge', 'leo/unittests/core/test_leoBridge.py')
75#@+node:ekr.20210911072153.7: *3* cover-checker-commands
76@g.command('cover-checker-commands')
77def cover_checker_commands(event=None):
78    """Run all coverage tests for leoCheckerCommands.py."""
79    g.run_coverage_tests('leo.commands.checkerCommands', 'leo/unittests/commands/test_checkerCommands.py')
80#@+node:ekr.20210911072153.8: *3* cover-colorizer
81@g.command('cover-colorizer')
82def cover_colorizer(event=None):
83    """Run all coverage tests for leoColorizer.py."""
84    g.run_coverage_tests('leo.core.leoColorizer', 'leo/unittests/core/test_leoColorizer.py')
85#@+node:ekr.20210911072153.10: *3* cover-commands
86@g.command('cover-commands')
87def cover_commands(event=None):
88    """Run all coverage tests for leoCommands.py."""
89    g.run_coverage_tests('leo.core.leoCommands', 'leo/unittests/core/test_leoCommands.py')
90#@+node:ekr.20220109041701.1: *3* cover-convert
91@g.command('cover-convert-commands')
92def cover_convert_commands(event=None):
93    """Run all coverage tests for convertCommands.py."""
94    g.run_coverage_tests('leo.commands.convertCommands', 'leo/unittests/commands/test_convertCommands.py')
95#@+node:ekr.20210911072153.9: *3* cover-config
96@g.command('cover-config')
97def cover_config(event=None):
98    """Run all coverage tests for leoConfig.py."""
99    g.run_coverage_tests('leo.core.leoConfig', 'leo/unittests/core/test_leoConfig.py')
100#@+node:ekr.20210907103024.6: *3* cover-edit-commands
101@g.command('cover-edit-commands')
102def cover_edit_commands(event=None):
103    """Run all coverage tests for leoEditCommands.py."""
104    g.run_coverage_tests('leo.commands.editCommands', 'leo/unittests/commands/test_editCommands.py')
105#@+node:ekr.20210911072153.12: *3* cover-external-files
106@g.command('cover-external-files')
107def cover_external_files(event=None):
108    """Run all coverage tests for leoExternalFiles.py."""
109    g.run_coverage_tests('leo.core.leoExternalFiles', 'leo/unittests/core/test_leoExternalFiles.py')
110#@+node:ekr.20210911072153.14: *3* cover-file-commands
111@g.command('cover-file-commands')
112def cover_file_commands(event=None):
113    """Run all coverage tests for leoFileCommands.py."""
114    g.run_coverage_tests('leo.core.leoFileCommands', 'leo/unittests/core/test_leoFileCommands.py')
115#@+node:ekr.20210907103024.7: *3* cover-find
116@g.command('cover-find')
117def cover_find(event=None):
118    """Run all coverage tests for leoFind.py."""
119    g.run_coverage_tests('leo.core.leoFind', 'leo/unittests/core/test_leoFind.py')
120#@+node:ekr.20210911072153.15: *3* cover-frame
121@g.command('cover-frame')
122def cover_frame(event=None):
123    """Run all coverage tests for leoFrame.py."""
124    g.run_coverage_tests('leo.core.leoFrame', 'leo/unittests/core/test_leoFrame.py')
125#@+node:ekr.20210911072153.16: *3* cover-globals
126@g.command('cover-globals')
127def cover_globals(event=None):
128    """Run all coverage tests for leoGlobals.py."""
129    g.run_coverage_tests('leo.core.leoGlobals', 'leo/unittests/core/test_leoGlobals.py')
130#@+node:ekr.20210911072153.18: *3* cover-import
131@g.command('cover-import')
132def cover_import(event=None):
133    """Run all coverage tests for leoImport.py."""
134    g.run_coverage_tests('leo.core.leoImport', 'leo/unittests/core/test_leoImport.py')
135#@+node:ekr.20210911072153.19: *3* cover-keys
136@g.command('cover-keys')
137def cover_keys(event=None):
138    """Run all coverage tests for leoKeys.py."""
139    g.run_coverage_tests('leo.core.leoKeys', 'leo/unittests/core/test_leoKeys.py')
140#@+node:ekr.20210911072153.20: *3* cover-leoserver
141@g.command('cover-leoserver')
142def cover_leoserver(event=None):
143    """Run all unittests for leoserver.py"""
144    g.run_coverage_tests('leo.core.leoserver', 'leo/unittests/core/test_leoserver.py')
145#@+node:ekr.20210907103024.8: *3* cover-nodes
146@g.command('cover-nodes')
147def cover_node(event=None):
148    """Run all coverage tests for leoNodes.py."""
149    g.run_coverage_tests('leo.core.leoNodes', 'leo/unittests/core/test_leoNodes.py')
150#@+node:ekr.20210911072153.23: *3* cover-persistence
151@g.command('cover-persistence')
152def cover_persistence(event=None):
153    """Run all coverage tests for leoPersistence.py."""
154    g.run_coverage_tests('leo.core.leoPersistence', 'leo/unittests/core/test_leoPersistence.py')
155#@+node:ekr.20210911072153.25: *3* cover-rst
156@g.command('cover-rst')
157def cover_rst3(event=None):
158    """Run all coverage tests for leoRst.py."""
159    g.run_coverage_tests('leo.core.leoRst', 'leo/unittests/core/test_leoRst.py')
160#@+node:ekr.20210911072153.26: *3* cover-shadow
161@g.command('cover-shadow')
162def cover_shadow(event=None):
163    """Run all coverage tests for leoShadow.py."""
164    g.run_coverage_tests('leo.core.leoShadow', 'leo/unittests/core/test_leoShadow.py')
165#@+node:ekr.20210911072153.28: *3* cover-undo
166@g.command('cover-undo')
167def cover_undo(event=None):
168    """Run all coverage tests for leoUndo.py."""
169    g.run_coverage_tests('leo.core.leoUndo', 'leo/unittests/core/test_leoUndo.py')
170#@+node:ekr.20210911072153.29: *3* cover-vim
171@g.command('cover-vim')
172def cover_vim(event=None):
173    """Run all coverage tests for leoVim.py."""
174    g.run_coverage_tests('leo.core.leoVim', 'leo/unittests/core/test_leoVim.py')
175#@+node:ekr.20210907113937.1: ** unit test commands...
176#@+node:ekr.20210907103024.11: *3* test-all
177@g.command('test-all')
178def test_all(event=None):
179    """Run all unit tests in leo.unittests."""
180    g.run_unit_tests()
181    # g.es_print('test-all: all tests complete')
182#@+node:ekr.20210907103024.12: *3* test-app
183@g.command('test-app')
184def test_app(event=None):
185    """Run all unit tests for leoApp.py."""
186    g.run_unit_tests('leo.unittests.core.test_leoApp')
187#@+node:ekr.20210907103024.13: *3* test-ast
188@g.command('test-ast')
189def test_ast(event=None):
190    """Run all unit tests for leoAst.py."""
191    g.run_unit_tests('leo.unittests.core.test_leoAst')
192#@+node:ekr.20210907103024.14: *3* test-atfile
193@g.command('test-atfile')
194def test_atfile(event=None):
195    """Run all unit tests for leoAtFile.py."""
196    g.run_unit_tests('leo.unittests.core.test_leoAtFile')
197#@+node:ekr.20210907103024.15: *3* test-bridge
198@g.command('test-bridge')
199def test_bridge(event=None):
200    """Run all unit tests for leoBridge.py."""
201    g.run_unit_tests('leo.unittests.core.test_leoBridge')
202#@+node:ekr.20210907103024.16: *3* test-checker-commands
203@g.command('test-checker-commands')
204def test_checker_commands(event=None):
205    """Run all unit tests for leoCheckerCommands.py."""
206    g.run_unit_tests('leo.unittests.commands.test_leoCheckerCommands')
207#@+node:ekr.20210907103024.17: *3* test-colorizer
208@g.command('test-colorizer')
209def test_colorizer(event=None):
210    """Run all unit tests for leoColorizer.py."""
211    g.run_unit_tests('leo.unittests.core.test_leoColorizer')
212#@+node:ekr.20211013080906.1: *3* test-convert
213@g.command('test-convert')
214def test_convert(event=None):
215    """Run all unit tests for leo/commands/leoConvertCommands.py."""
216    g.run_unit_tests('leo.unittests.commands.test_convertCommands')
217        #.TestPythonToTypeScript')
218#@+node:ekr.20210907103024.18: *3* test-commands
219@g.command('test-commands')
220def test_commands(event=None):
221    """Run all unit tests for leoCommands.py."""
222    g.run_unit_tests('leo.unittests.core.test_leoCommands')
223#@+node:ekr.20210910074026.1: *3* test-config
224@g.command('test-config')
225def test_config(event=None):
226    """Run all unit tests for leoConfig.py."""
227    g.run_unit_tests('leo.unittests.core.test_leoConfig')
228#@+node:ekr.20210926051147.1: *3* test-doctests
229@g.command('test-doctests')
230def test_doctests(event=None):
231    """Run all doctests in Leo."""
232    g.run_unit_tests('leo.unittests.test_doctests')
233#@+node:ekr.20210907103024.19: *3* test-edit-commands
234@g.command('test-edit-commands')
235def test_edit_commands(event=None):
236    """Run all unit tests for leo.commands.editCommands."""
237    g.run_unit_tests('leo.unittests.commands.test_editCommands')
238#@+node:ekr.20210907103024.20: *3* test-external-files
239@g.command('test-external-files')
240def test_external_files(event=None):
241    """Run all unit tests for leoExternalFiles.py."""
242    g.run_unit_tests('leo.unittests.core.test_leoExternalFiles')
243#@+node:ekr.20210910065945.1: *3* test-file-commands
244@g.command('test-file-commands')
245def test_file_commands(event=None):
246    """Run all unit tests for leoFileCommands.py."""
247    g.run_unit_tests('leo.unittests.core.test_leoFileCommands')
248#@+node:ekr.20210907103024.21: *3* test-find
249@g.command('test-find')
250def test_find(event=None):
251    """Run all unit tests for leoFind.py."""
252    g.run_unit_tests('leo.unittests.core.test_leoFind.')
253#@+node:ekr.20210907103024.22: *3* test-frame
254@g.command('test-frame')
255def test_frame(event=None):
256    """Run all unit tests for leoFrame.py."""
257    g.run_unit_tests('leo.unittests.core.test_leoFrame')
258#@+node:ekr.20210907103024.23: *3* test-globals
259@g.command('test-globals')
260def test_globals(event=None):
261    """Run all unit tests for leoGlobals.py."""
262    g.run_unit_tests('leo.unittests.core.test_leoGlobals')
263#@+node:ekr.20210907103024.24: *3* test-import
264@g.command('test-import')
265def test_import(event=None):
266    """Run all unit tests for leoImport.py."""
267    g.run_unit_tests('leo.unittests.core.test_leoImport')
268#@+node:ekr.20210907103024.25: *3* test-keys
269@g.command('test-keys')
270def test_keys(event=None):
271    """Run all unit tests for leoKeys.py."""
272    g.run_unit_tests('leo.unittests.core.test_leoKeys.TestKeys')
273#@+node:ekr.20210907103024.29: *3* test-leoserver
274@g.command('test-leoserver')
275def test_leoserver(event=None):
276    """Run all unittests for leoserver.py"""
277    g.run_unit_tests('leo.unittests.core.test_leoserver')
278#@+node:ekr.20210907103024.10: *3* test-leoserver-with-leoclient
279@g.command('test-leoserver-with-leoclient')
280def test_leo_client_and_server(event=None):
281    """
282    Test leoserver.py with leoclient.py.
283    
284    The test-all command does *not* run this command, because there is
285    no corresponding test*.py file.
286    """
287    g.cls()
288    leo_dir = os.path.abspath(os.path.join(g.app.loadDir, '..', '..'))
289    assert os.path.exists(leo_dir), repr(leo_dir)
290    os.chdir(leo_dir)
291    g.execute_shell_commands('start cmd /k "python -m leo.core.leoserver --trace=request,response,verbose"')
292    time.sleep(1.5)
293    g.execute_shell_commands('start cmd /k "python -m leo.core.leoclient"')
294#@+node:ekr.20210907103024.26: *3* test-nodes
295@g.command('test-nodes')
296def test_nodes(event=None):
297    """Run all unit tests for leoNodes.py."""
298    g.run_unit_tests('leo.unittests.core.test_leoNodes')
299#@+node:ekr.20210909091424.1: *3* test-persistence
300@g.command('test-persistence')
301def test_persistence(event=None):
302    """Run all unit tests for leoPersistence.py."""
303    g.run_unit_tests('leo.unittests.core.test_leoPersistence')
304#@+node:ekr.20210907103024.27: *3* test-plugins
305@g.command('test-plugins')
306def test_plugins(event=None):
307    """Run all unit tests relating to plugins."""
308    g.run_unit_tests('leo.unittests.test_plugins')
309#@+node:ekr.20210907103024.28: *3* test-rst
310@g.command('test-rst')
311def test_rst3(event=None):
312    """Run all unit tests for leoRst.py."""
313    g.run_unit_tests('leo.unittests.core.test_leoRst')
314#@+node:ekr.20210907103024.30: *3* test-shadow
315@g.command('test-shadow')
316def test_shadow(event=None):
317    """Run all unit tests for leoShadow.py."""
318    g.run_unit_tests('leo.unittests.core.test_leoShadow')
319#@+node:ekr.20210907103024.31: *3* test-syntax
320@g.command('test-syntax')
321def test_syntax(event=None):
322    """Run all testss in test_syntax.py."""
323    g.run_unit_tests('leo.unittests.test_syntax')
324#@+node:ekr.20210907103024.32: *3* test-undo
325@g.command('test-undo')
326def test_undo(event=None):
327    """Run all unit tests for leoUndo.py."""
328    g.run_unit_tests('leo.unittests.core.test_leoUndo')
329#@+node:ekr.20210910073036.1: *3* test-vim
330@g.command('test-vim')
331def test_vim(event=None):
332    """Run all unit tests for leoVim.py."""
333    g.run_unit_tests('leo.unittests.core.test_leoVim')
334#@+node:ekr.20210910085337.1: *3* test_gui
335@g.command('test-gui')
336def test_gui(event=None):
337    """Run all gui-related unit tests."""
338    g.run_unit_tests('leo.unittests.test_gui.TestNullGui')
339    g.run_unit_tests('leo.unittests.test_gui.TestQtGui')
340#@-others
341#@@language python
342#@@tabwidth -4
343#@@pagewidth 70
344#@-leo
345
Full Screen

SConstruct

Source: SConstruct Github

copy
1# vim:ai:et:ff=unix:fileencoding=utf-8:sw=4:syntax=python:ts=4:
2# conveyor/SConstruct
3#
4# Copyright © 2012 Matthew W. Samsonoff <[email protected]>
5#
6# This program is free software: you can redistribute it and/or modify it under
7# the terms of the GNU Affero General Public License as published by the Free
8# Software Foundation, either version 3 of the License, or (at your option) any
9# later version.
10#
11# This program is distributed in the hope that it will be useful, but WITHOUT
12# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13# FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
14# details.
15#
16# You should have received a copy of the GNU Affero General Public License
17# along with this program. If not, see <http://www.gnu.org/licenses/>.
18
19import sys, os
20
21
22AddOption('--unit_tests', default=None, dest='unit_test')
23build_unit_tests = False
24run_unit_tests = False
25testmode = GetOption('unit_test')
26
27AddOption('--test', action='store_true', dest='test')
28if GetOption('test'):
29    testmode = 'run'
30
31#not used, added for consistency
32AddOption('--debug_build', action='store_true', dest='debug_build')
33debug = GetOption('debug_build')
34
35if testmode is not None:
36    if testmode == 'run':
37        build_unit_tests = True
38        run_unit_tests = True
39    elif testmode == 'build':
40        build_unit_tests = True
41
42env = Environment(ENV=os.environ)
43
44if run_unit_tests:
45    if 'win32' == sys.platform:
46        env.Command('test', 'test.bat', 'test.bat')
47    else: 
48        env.Command('test', 'test.sh', '. virtualenv/bin/activate; ./test.sh')
49
50Export('build_unit_tests', 'run_unit_tests')
51
52print "build_unit_tests " + str(build_unit_tests)
53
54## For building C++/Qt creation
55SConscript('SConscript', variant_dir='obj', duplicate=1, export='build_unit_tests')
56
Full Screen

unit_tests.py

Source: unit_tests.py Github

copy
1# From python
2import os
3import numpy as np
4
5# From Squid
6from squid import geometry
7from squid import structures
8
9# From PAL
10import pal
11#import pal.stats
12#import pal.utils
13#import pal.kernels
14import pal.constants.world as WORLD_CONSTS
15
16
17def test_path_variables():
18    PATHS = [
19        WORLD_CONSTS.BINDING_ENERGY_DATABASE,
20        WORLD_CONSTS.STRUCTURES_PATH
21    ]
22    return all([
23        os.path.isdir(s)
24        for s in PATHS if s is not None
25    ] + [
26        s.endswith("/")
27        for s in PATHS if s is not None
28    ])
29
30
31def test_change_in_theory():
32    return all([
33        x == y for x, y in zip(
34            ["! HF SV ECP{def2-TZVP}",
35             "! OPT B97-D3 SV GCP(DFT/TZ) ECP{def2-TZVP} Grid7 SlowConv",
36             "! OPT B97-D3 def2-TZVP GCP(DFT/TZ) ECP{def2-TZVP} Grid7 SlowConv",
37             "! OPT PW6B95 def2-TZVP GCP(DFT/TZ) ECP{def2-TZVP} Grid7 SlowConv"],
38            WORLD_CONSTS.default_routes)
39    ] + ['''%geom
40    MaxIter 1000
41    end
42''' == WORLD_CONSTS.extra_section])
43
44
45def run_unit_tests():
46    # The stats module
47    pal.stats.MAP.run_unit_tests()
48    pal.stats.MLE.run_unit_tests()
49    pal.stats.priors.run_unit_tests()
50    pal.stats.bayesian.run_unit_tests()
51    pal.stats.likelihood.run_unit_tests()
52    pal.stats.hyperparameters.run_unit_tests()
53    pal.stats.knowledge_gradient.run_unit_tests()
54
55    # The acquisition module
56    pal.EI.run_unit_tests()
57    pal.kg.run_unit_tests()
58    pal.misokg.run_unit_tests()
59
60    # The Kernels modules
61    pal.kernels.matern.run_unit_tests()
62    pal.kernels.periodic.run_unit_tests()
63
64    # The Utils modules
65    pal.utils.parser.run_unit_tests()
66    pal.utils.strings.run_unit_tests()
67    pal.utils.generate_systems.run_unit_tests()
68
69    # Additional unit tests
70    assert test_path_variables(), "pal.constants.world has invalid path variables."
71    assert test_change_in_theory(), "A change in pal.constants.world.route or .extra_section means compatability issues with the database!"
72
73    print("\nSUCCESS! ALL TESTS HAVE PASSED.")
74
75
76if __name__ == "__main__":
77    run_unit_tests()
78
Full Screen

Accelerate Your Automation Test Cycles With LambdaTest

Leverage LambdaTest’s cloud-based platform to execute your automation tests in parallel and trim down your test execution time significantly. Your first 100 automation testing minutes are on us.

Try LambdaTest

Run Python Tests on LambdaTest Cloud Grid

Execute automation tests with SeleniumLibrary on a cloud-based Grid of 3000+ real browsers and operating systems for both web and mobile applications.

Test now for Free
LambdaTestX

We use cookies to give you the best experience. Cookies help to provide a more personalized experience and relevant advertising for you, and web analytics for us. Learn More in our Cookies policy, Privacy & Terms of service

Allow Cookie
Sarah

I hope you find the best code examples for your project.

If you want to accelerate automated browser testing, try LambdaTest. Your first 100 automation testing minutes are FREE.

Sarah Elson (Product & Growth Lead)