def start(): argv = ['react', 'discover'] if len(sys.argv) > 1: argv = sys.argv react.set_up() unittest.main(module=None, argv=argv)
def test_set_up(self): """ It should call utils.setup """ with patch('react.utils.set_up', autospec=True) as s: with patch('react.utils.run_script', autospec=True) as r: react.set_up() s.assert_called_once_with() r.assert_called_once_with(_DEFINE_GLOBALS_SCRIPT)
# -*- coding: utf-8 -*- # Build examples without installing # python-react-v8 or messing with sys.path if __name__ == '__main__': import react react.set_up() from examples.simple import build from examples.flux import build as build_flux build.do_build() build_flux.do_build()
</html> """ def write_index(): data = {'initialCount': 10} react = React({ 'component': 'Counter', 'data': data}) with open(OUTPUT_PATH, 'w', encoding='utf-8') as fh: fh.write(template.format( pre_rendered_content=react.render(), pre_loaded_state=react.to_json(data))) def load_libs(): utils.load_libs([BUNDLE_PATH]) def do_build(): load_libs() write_index() if __name__ == '__main__': import react react.set_up() do_build()