def test_test(self): if sys.version < "2.6" or hasattr(sys, 'real_prefix'): return dist = Distribution(dict( name='foo', packages=['name', 'name.space', 'name.space.tests'], namespace_packages=['name'], test_suite='name.space.tests.test_suite', use_2to3=True, )) dist.script_name = 'setup.py' cmd = test(dist) cmd.user = 1 cmd.ensure_finalized() cmd.install_dir = site.USER_SITE cmd.user = 1 old_stdout = sys.stdout sys.stdout = StringIO() try: try: # try/except/finally doesn't work in Python 2.4, so we need nested try-statements. cmd.run() except SystemExit: # The test runner calls sys.exit, stop that making an error. pass finally: sys.stdout = old_stdout
def test_tests_are_run_once(capfd): params = dict( name='foo', packages=['dummy'], ) with open('setup.py', 'wt') as f: f.write('from setuptools import setup; setup(\n') for k, v in sorted(params.items()): f.write(' %s=%r,\n' % (k, v)) f.write(')\n') os.makedirs('dummy') with open('dummy/__init__.py', 'wt'): pass with open('dummy/test_dummy.py', 'wt') as f: f.write( DALS(""" import unittest class TestTest(unittest.TestCase): def test_test(self): print('Foo') """)) dist = Distribution(params) dist.script_name = 'setup.py' cmd = test(dist) cmd.ensure_finalized() cmd.run() out, err = capfd.readouterr() assert out == 'Foo\n'
def test_test(self): if sys.version < "2.6" or hasattr(sys, 'real_prefix'): return dist = Distribution( dict( name='foo', packages=['name', 'name.space', 'name.space.tests'], namespace_packages=['name'], test_suite='name.space.tests.test_suite', use_2to3=True, )) dist.script_name = 'setup.py' cmd = test(dist) cmd.user = 1 cmd.ensure_finalized() cmd.install_dir = site.USER_SITE cmd.user = 1 old_stdout = sys.stdout sys.stdout = StringIO() try: try: # try/except/finally doesn't work in Python 2.4, so we need nested try-statements. cmd.run() except SystemExit: # The test runner calls sys.exit, stop that making an error. pass finally: sys.stdout = old_stdout
def more_train(): (train_in, train_out) = get_train_data() (test_in, test_out) = test() tm = [] x = [] y = [] y_test = [] for i in train_out: y.append(i[0]) for i in test_out: y_test.append(i[0]) model = tf.keras.models.Sequential([ tf.keras.layers.Flatten(input_shape=(1300, )), tf.keras.layers.Dense(16, activation=tf.nn.relu), tf.keras.layers.Dense(16, activation=tf.nn.relu), tf.keras.layers.Dropout(0.5), tf.keras.layers.Dense(3, activation=tf.nn.softmax) ]) model.compile(optimizer='adam', loss='sparse_categorical_crossentropy', metrics=['accuracy']) model.fit(np.array(train_in), np.array(y), epochs=50) # model.evaluate(np.array(test_in), np.array(y_test)) model.save('my_model_2.h5')
def test_tests_are_run_once(capfd): params = dict(packages=['dummy'], ) files = { 'setup.py': 'from setuptools import setup; setup(' + ','.join(f'{name}={params[name]!r}' for name in params) + ')', 'dummy': { '__init__.py': '', 'test_dummy.py': DALS(""" import unittest class TestTest(unittest.TestCase): def test_test(self): print('Foo') """), }, } path.build(files) dist = Distribution(params) dist.script_name = 'setup.py' cmd = test(dist) cmd.ensure_finalized() cmd.run() out, err = capfd.readouterr() assert out.endswith('Foo\n') assert len(out.split('Foo')) == 2
def test_tests_are_run_once(capfd): params = dict( name='foo', packages=['dummy'], ) with open('setup.py', 'wt') as f: f.write('from setuptools import setup; setup(\n') for k, v in sorted(params.items()): f.write(' %s=%r,\n' % (k, v)) f.write(')\n') os.makedirs('dummy') with open('dummy/__init__.py', 'wt'): pass with open('dummy/test_dummy.py', 'wt') as f: f.write(DALS( """ from __future__ import print_function import unittest class TestTest(unittest.TestCase): def test_test(self): print('Foo') """)) dist = Distribution(params) dist.script_name = 'setup.py' cmd = test(dist) cmd.ensure_finalized() # The test runner calls sys.exit with contexts.suppress_exceptions(SystemExit): cmd.run() out, err = capfd.readouterr() assert out == 'Foo\n'
def test_test(capfd): params = dict( name='foo', packages=['name', 'name.space', 'name.space.tests'], namespace_packages=['name'], test_suite='name.space.tests.test_suite', use_2to3=True, ) dist = Distribution(params) dist.script_name = 'setup.py' cmd = test(dist) cmd.ensure_finalized() cmd.run() out, err = capfd.readouterr() assert out == 'Foo\n'
def test_deprecation_stderr(capfd): params = dict(name='foo', packages=['name', 'name.space', 'name.space.tests'], namespace_packages=['name'], test_suite='name.space.tests.test_suite', use_2to3=True) dist = Distribution(params) dist.script_name = 'setup.py' cmd = test(dist) cmd.ensure_finalized() cmd.run() out, err = capfd.readouterr() msg = ("WARNING: Testing via this command is deprecated and will be " "removed in a future version. Users looking for a generic test " "entry point independent of test runner are encouraged to use " "tox.\n") assert msg in err
def test_test(capfd): params = dict( name='foo', packages=['name', 'name.space', 'name.space.tests'], namespace_packages=['name'], test_suite='name.space.tests.test_suite', use_2to3=True, ) dist = Distribution(params) dist.script_name = 'setup.py' cmd = test(dist) cmd.ensure_finalized() # The test runner calls sys.exit with contexts.suppress_exceptions(SystemExit): cmd.run() out, err = capfd.readouterr() assert out == 'Foo\n'
def test_test(self): params = dict( name='foo', packages=['name', 'name.space', 'name.space.tests'], namespace_packages=['name'], test_suite='name.space.tests.test_suite', use_2to3=True, ) dist = Distribution(params) dist.script_name = 'setup.py' cmd = test(dist) cmd.user = 1 cmd.ensure_finalized() cmd.install_dir = site.USER_SITE cmd.user = 1 with contexts.quiet(): # The test runner calls sys.exit with contexts.suppress_exceptions(SystemExit): cmd.run()
def __init__(self, distribution): self._test = test.test(distribution) QipCommandBase.__init__(self, distribution)
dist = Distribution(dict( >>>>>>> e4baf504ede925f4f1e07d823c9b20b3d0dbe14c name='foo', packages=['name', 'name.space', 'name.space.tests'], namespace_packages=['name'], test_suite='name.space.tests.test_suite', use_2to3=True, <<<<<<< HEAD ) dist = Distribution(params) ======= )) >>>>>>> e4baf504ede925f4f1e07d823c9b20b3d0dbe14c dist.script_name = 'setup.py' cmd = test(dist) cmd.user = 1 cmd.ensure_finalized() cmd.install_dir = site.USER_SITE cmd.user = 1 <<<<<<< HEAD with contexts.quiet(): # The test runner calls sys.exit with contexts.suppress_exceptions(SystemExit): cmd.run() ======= old_stdout = sys.stdout sys.stdout = StringIO() try: try: # try/except/finally doesn't work in Python 2.4, so we need nested try-statements. cmd.run()