How to use test_underscore method in molecule

Best Python code snippet using molecule_python

conf_fortran.py

Source:conf_fortran.py Github

copy

Full Screen

1# mathtext - A TeX/LaTeX compatible rendering library. Copyright (C)2# 2008-2012 Yue Shi Lai <ylai@users.sourceforge.net>3#4# This library is free software; you can redistribute it and/or modify5# it under the terms of the GNU Lesser General Public License as6# published by the Free Software Foundation; either version 2.1 of the7# License, or (at your option) any later version.8#9# This library is distributed in the hope that it will be useful, but10# WITHOUT ANY WARRANTY; without even the implied warranty of11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU12# Lesser General Public License for more details.13#14# You should have received a copy of the GNU Lesser General Public15# License along with this library; if not, write to the Free Software16# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA17# 02110-1301 USA18import os, re, subprocess19def conftest_file(configuration, index, extension):20 return configuration.env.File(os.path.join(21 '$CONFIGUREDIR',22 'conftest_fortran_%d%s' % (index, extension)))23def config_fortran_link(configuration):24 file_target = conftest_file(configuration, 0, '')25 file_source = conftest_file(configuration, 0, '.f')26 filename_target = str(file_target)27 filename_source = str(file_source)28 file = open(filename_source, 'w')29 try:30 file.write(' PROGRAM MAIN\n END\n')31 finally:32 file.close()33 command = configuration.env.subst(34 '$FORTRAN -v -o $TARGET $SOURCES',35 target = file_target, source = file_source)36 child = subprocess.Popen(37 command, shell = True,38 stdin = subprocess.PIPE, stdout = subprocess.PIPE,39 stderr = subprocess.PIPE, close_fds = True)40 child.stdout.read()41 content = re.compile('[ \t\n]+').split(child.stderr.read())42 for f in filename_source, filename_target:43 if os.path.exists(f):44 os.remove(f)45 libs = []46 libpath = []47 rpath = []48 for e in content:49 if e[:2] == '-l':50 libs.append(e[2:])51 if e[:2] == '-L':52 libpath.append(e[2:])53 if e[:2] == '-R':54 rpath.append(e[2:])55 if configuration.env['FORTRAN'][-5:] == 'ifort' and \56 'svml' not in libs:57 configuration.env.SetDefault(58 FORTRANLIBS = libs + ['svml'])59 else:60 configuration.env.SetDefault(FORTRANLIBS = libs)61 configuration.env.SetDefault(FORTRANLIBPATH = libpath)62 configuration.env.SetDefault(FORTRANRPATH = rpath)63def config_fortran_mangling(configuration):64 file_target = (conftest_file(configuration, 1, '.o'),65 conftest_file(configuration, 2, ''))66 file_source = (conftest_file(configuration, 1, '.f'),67 conftest_file(configuration, 2, '.c'))68 filename_target = map(str, file_target)69 filename_source = map(str, file_source)70 file = open(filename_source[0], 'w')71 try:72 file.write(' SUBROUTINE FOOBAR()\n RETURN\n' +73 ' END\n SUBROUTINE FOO_BAR()\n' +74 ' RETURN\n END\n')75 finally:76 file.close()77 command = configuration.env.subst(78 '$FORTRAN -o $TARGET -c $SOURCES',79 target = file_target[0], source = file_source[0])80 child = subprocess.Popen(81 command, shell = True,82 stdin = subprocess.PIPE, stdout = subprocess.PIPE,83 stderr = subprocess.PIPE, close_fds = True)84 child.stdout.read()85 child.stderr.read()86 if not os.path.exists(filename_target[0]):87 return88 command = configuration.env.subst(89 '$CC -o $TARGET $SOURCES',90 target = file_target[1],91 source = [file_target[0], file_source[1]])92 test_prefix = None93 for test_case in 'foobar', 'FOOBAR':94 for test_underscore in '', '_':95 file = open(filename_source[1], 'w')96 try:97 file.write('extern int ' + test_case +98 test_underscore + '(void);\nint main(' + \99 'void)\n{\n\treturn ' + test_case +100 test_underscore + '();\n}\n')101 finally:102 file.close()103 child = subprocess.Popen(104 command, shell = True,105 stdin = subprocess.PIPE, stdout = subprocess.PIPE,106 stderr = subprocess.PIPE, close_fds = True)107 child.stdout.read()108 child.stderr.read()109 if os.path.exists(filename_target[1]):110 test_prefix = test_case[:3] + '_' + test_case[3:] + \111 test_underscore112 uppercase = test_case == 'FOOBAR'113 underscore = [test_underscore == '_', None]114 break115 if test_prefix != None:116 break117 if test_prefix == None:118 return119 for test_underscore in '', '_':120 file = open(filename_source[1], 'w')121 try:122 file.write('extern int ' + test_prefix +123 test_underscore + '(void);\nint main(' + \124 'void)\n{\n\treturn ' + test_prefix +125 test_underscore + '();\n}\n')126 finally:127 file.close()128 child = subprocess.Popen(129 command, shell = True,130 stdin = subprocess.PIPE, stdout = subprocess.PIPE,131 stderr = subprocess.PIPE, close_fds = True)132 child.stdout.read()133 child.stderr.read()134 if os.path.exists(filename_target[1]):135 underscore[1] = test_underscore == '_'136 break137 if underscore[1] == None:138 return139 for f in filename_source + filename_target:140 if os.path.exists(f):141 os.remove(f)142 if uppercase:143 name_case = 'NAME'144 else:145 name_case = 'name'146 if underscore[0]:147 suffix = [' ## _', ' ## _']148 else:149 suffix = ['', '']150 if underscore[1]:151 if suffix[1] == '':152 suffix[1] += ' ## '153 suffix[1] += '_'154 cppdefines = [('F77_FUNC(name, NAME)', name_case + suffix[0]),155 ('F77_FUNC_(name, NAME)', name_case + suffix[1])]156 configuration.env.Append(CPPDEFINES = cppdefines)157def config(configuration):158 configuration.Message('Checking for the Fortran compiler ' +159 'mangling/linkage... ')160 config_fortran_link(configuration)161 config_fortran_mangling(configuration)162 ret = 1163 configuration.Result(ret)...

Full Screen

Full Screen

Underscore_Example.py

Source:Underscore_Example.py Github

copy

Full Screen

1class Test_Underscore:2 def __init__(self):3 self.foo = 114 self._bar = 235 self.__baz = 236t = Test_Underscore()7print(dir(t))8class Test_Extended(Test_Underscore):9 def __init__(self):10 super().__init__()11 self.foo = 'overriden'12 self._bar = 'overriden'13 self.__baz = 'overriden'14class ManglingTest:15 def __init__(self):16 self.__mangled = 'Hello'17 def get_mangled(self):18 return self.__mangled19t2 = Test_Extended()20print(t2._Test_Underscore__baz)21print(t2.foo)22print(t2._bar)23print(t2.__baz)...

Full Screen

Full Screen

test_misc.py

Source:test_misc.py Github

copy

Full Screen

1#schnuckenack-test.py2import unittest, os34from utils import Fixture, runtests56from model_examples import Car, Brand, Manufacturer, Driver, Key7from heinzel.core import models8910models.register([Car, Brand, Manufacturer, Driver, Key])1112DBNAME = "test.db"131415class TestMisc(Fixture):1617 def runTest(self):18 test_underscore = Car(name="Test_underscore")19 test_underscore.save()20 self.assert_(Car.objects.filter(name="Test_underscore")[0] is test_underscore)2122 23if __name__ == "__main__":24 alltests = (25 TestMisc,26 ) ...

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