Writing a pytest function for checking the output on console (stdout)

Use the capfd fixture. Example: def test_foo(capfd): foo() # Writes “Hello World!” to stdout out, err = capfd.readouterr() assert out == “Hello World!” See: http://pytest.org/en/latest/fixture.html for more details And see: py.test –fixtures for a list of builtin fixtures. Your example has a few problems. Here is a corrected version: def f(name): print “hello {}”.format(name) def … Read more

Loop a multidimensional array and only print two specific column values per row

Using a foreach loop without a key: foreach($array as $item) { echo $item[‘filename’]; echo $item[‘filepath’]; // To know what’s in $item echo ‘<pre>’; var_dump($item); } Using a foreach loop with a key: foreach($array as $i => $item) { echo $array[$i][‘filename’]; echo $array[$i][‘filepath’]; // $array[$i] is same as $item } Using a for loop: for ($i … Read more

How can I print multiple things on the same line, one at a time?

Python 3 Solution The print() function accepts an end parameter which defaults to \n (new line). Setting it to an empty string prevents it from issuing a new line at the end of the line. def install_xxx(): print(“Installing XXX… “, end=””, flush=True) install_xxx() print(“[DONE]”) Python 2 Solution Putting a comma on the end of the … Read more

How can I print multiple things (fixed text and/or variable values) on the same line, all at once?

There are many ways to do this. To fix your current code using %-formatting, you need to pass in a tuple: Pass it as a tuple: print(“Total score for %s is %s” % (name, score)) A tuple with a single element looks like (‘this’,). Here are some other common ways of doing it: Pass it … Read more

Page numbers with CSS/HTML

Depending on your required browser support. @page { @bottom-right { content: counter(page) ” of ” counter(pages); } } Further reading: http://www.w3.org/TR/css3-page/ http://www.intelligrape.com/blog/2010/08/20/add-page-number-using-page-property-of-css/ http://www.princexml.com/doc/6.0/page-numbers/

how to print database diagram sql

On SQL Server Management Studio In the Database Diagram, right click and select ‘View Page Breaks’ Then from main window menu select, File > Page Setup Select Page Size and Orientation – A3 and Landscape are most likely best options. And Print Scale – this is the % value that should hopefully enable you to … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)