How could I use pytest-html in Pycharm? - pytest

I have installed pytest-html and want to use it generate html report after run pytest in pycharm.
like this:
but it pops error:
ERROR: file not found: html=report\result.html
after run. So how to modify the arguments?

use
--html=Reports/Report.html --self-contained-html
in additional argument section of pycharm

If your using terminal to run the test try this instead this will work .
py.test --html=demoreport.html

If you want to run via pycharm, just by Right click on the project, follow below steps:
Add new configuration in Pycharm: At Configuration popup: Click '+', Python tests->pytest, provide "working directory" and "target" values with the path of the project.
Then after, Create a new file pytest.ini in the root folder of the project and provide the below values:
[pytest]
addopts = --html=reports/Report.html
python_files = tests/*.py
where, tests/*.py is a folder which contains all tests.
Now, just right click on your project and select Run 'pytest in ProjectFolderName' and you will find that report is created inside reports folder with name Report.html

Related

How to get compile/build date on Flutter App?

I know how to get the version using package_info, but how to get the build timestamp on Runtime both on ios and android?
You can use a build shell script that creates/updates a Dart file in lib/... with constants holding the date before running flutter build ....
You then import that file in your code and use it.
I'll suggest that you also consider basically rolling your own version of the package_info library which includes all the information you want to get from the platform code. I use the Gradle build files to update some variables on each build, which I then retrieve from Flutter.
Examining the package_info code shows that it is really a fairly simple MethodChannel use case. You could add anything that you can get from the native side.
Expanding on Günter Zöchbauer answer...
Create a text file in your source folder and enter the following
#!/bin/sh
var = "final DateTime buildDate =
DateTime.fromMillisecondsSinceEpoch(($(date "+%s000")));"
echo "$var" > lib/build_date.dart
Save the text file as
build_date_script.sh
In Android Studio, open Edit Configurations -> Add New Configuration and add a new 'Shell Script'
Give it a name, such as 'Write build date'
Select 'Script file' and enter the location of the 'build_date_script.sh' we created it stage 2.
Download and install GitBash https://gitforwindows.org/
Back to Android Studio, change the interpreter path to 'C:\Program Files\Git\git-bash.exe'.
Uncheck 'Execute in terminal' and click 'Apply'
Then in your main flutter run configuration, add a 'Before launch' item, select 'Run another configuration' and choose the script config we named in stage 4.
Click OK.
Now every time you build it will create a new dart file in your lib folder called 'build_date.dart' with a variable called 'buildDate' for use as a build date within your application.

Error running Go program

i'm trying to run a Go program and it always gives me this error i tried googling it but nothing can't see what's the problem! ScreenShot
Executable file (C:/Users!/ABDELLATIF-PC/Desktop/SimpleComputerRemote/Host/bin/server.exe) doesn't exist
Its a build issue. Check your bin folder
Whether program has access to the folder
Check preferences and missing references for the golang project.
The setup process should be driven by Host/install/windows/innosetup-x64.iss for InnoSetup:
You need to check if the setup properly installed the exe, and why it looks for C:/Users!/... instead of C:/Users/...
I managed to find the issue, It is no configuration issue or anything. You have to do 3 things as follows,
1) Make sure GOPATH value is different from GOROOT.
2) Make sure GOBIN value is empty.
3) Your package name on the go file in eclipse should be main and not the package name "hello". This should be the case for at least the file that has main function. To do this, File->New go file->Source file type should be -> Command source file-> Empty main function. Then type your code after which you can build to see the the .exe file in GOPATH/bin and the program run.
Worked for me.

how to setup grunt in webstorm on windows

I am Using Webstorm (PHPStorm) on Windows 7. On the actual project we are using grunt to concatenate javascript and css and also for several other build processes.
I tried to setup the grunt command as an external run command in Webstorm. The settings i tried for that are:
Name: grunt
Parameters: none
WorkingDirectory: $ProjectFileDir$
So now when I am trying to start my external run command in Webstorm, I always get the error
> grunt
Cannot run program "grunt" (in directory "C:\Users\jawidmer\workspaces\projectname"): CreateProcess error=2, The system cannot find the file specified
When I open my command line tool and navigate to the project folder, I can start grunt without any problems.
I already searched in google and tried all kinds of different combinations of settings but non of them worked..
Do you have any ideas, what I have to change to be able to start grunt from external run commands in Webstorm?
Thanks
Jan
By your description, I assume that the same way I configured it in my WebStorm installation should work just fine for you too:
I hope it helps.
UPDATE
It seems that if you add > %TEMP%\grunt & type %TEMP%\grunt & del %TEMP%\grunt to Parameters (like shown in the updated image), the build errors will be shown.
If you need to configure a task (for example grunt watch), the Parameters field must be the following:
watch > %TEMP%\grunt & type %TEMP%\grunt & del %TEMP%\grunt
Tip taken from here
Maybe this variant will be useful for somebody:
Settings -> External Tools
With this tool I can right-click folder in project and in context menu select grunt -> build
As I had problems with the path of node and grunt in linux. I've decide to add the following in Settings->External Tools, I guess in windows can be done in the same way (PHPstorm 7, in the same dialog as the prior answers):
Name: grunt Group: Node
Program: /opt/nodes/current/bin/node (my path to node files)
Parameters: /my/directory/node_modules/grunt-cli/bin/grunt watch (my path to grunt-cli binary and the parameter to the task of grunt)
Working directory: /home/user/project/ (my path to Gruntfile.js)

OpenERP 7 development environment: web module not found

I setup an Ubuntu environment and used bzr to get the 3 trunks: addons, server, web
Everything works and the server starts fine.
I then loaded the project in Eclipse and tried to run openerp-server. I got this error (module web: module not found). I then copied the entries (addons_path) in the openerp-server.conf from /etc/ to the conf file in server/install folder. I also created a copy of this file and pasted in server folder, in the hopes that eclipse would pick it up.
But I am still getting the same error. Three questions please:
Which conf file should I add this path for eclipse to use? Where does this file reside?
If I must use a command line switch to specify the web/addons path then how do I do that in eclipse?
There used to be a file with a lot of different variable such as pg_path, rpc, etc. Is that file still around? Maybe that is where I need to make this entry?
Thanks
I had to add a "-c /etc/openerp-server.conf" argument. Right click on the openerp-server file, launch the properties window, select Run/Debug Settings, select the only launch configuration available, edit, select the arguments tab.
I added them manually to eclipse run configurations > arguments.
e.g.
--db_host = {host}
--db_port = {port}
--db_user = {user}
--db_password = {password}
--addons = ../addons,../server/addons

PyDev Unit Test Set Run Directory

I have a PyDev unit test module that lives at the path:
$(PYDEV_PROJECT_ROOT)/tests/my_unit_test.py
I am attempting to use Eclipse PyDev's unit testing facilities. My unit test must read a configuration file like so:
(foo,bar,baz) = myModule.readOptimizationConfig("tests/optimization_config_file.cfg")
However, this will not work because PyDev goes into the 'tests' directory before running, and so specifying 'tests/' in the path given to readOptimizationConfig makes it attempt to load
$(PYDEV_PROJECT_ROOT)/tests/tests/optimization_config_file.cfg
However, I also need to run these tests using nosetests from the command lin.
This is because, in order to run ALL the tests for my project, rather than the option for running them in a particular file that is provided by default, the easiest solution was to just use the 'nosetests' command, rather than messing with Eclipse launch configurations. However, nosetests needs to be be run from the $(PYDEV_PROJECT_ROOT) root directory, so it needs the 'tests/' specified in the path.
Is there a way to force eclipse to run the unit tests from the project root directory, so that the paths that I pass to readOptimizationConfig will work for both methods?
It is possible to do this in PyDev, but you have to do it per every launch configuration so it's a bit boring.
Anyway, you first try to run as your script containing the unit-test (as you normally would - e.g. the dropdown menu next to the green "Run" arrow button then Run as... - Python unit-test). This launch will fail because of your missing cfg file. Now go to Run configurations (Run dropdown - Run configurations), open the Arguments tab and in the bottom under Working directory enter the path you want (or browse for it using the Workspace... button). For example if you want to run from project root and your project is called awesome-project, you would write:
${workspace_loc:awesome-project}
Now you should have a valid launch configuration that you can use from both the Run and Debug menus. I sometimes rename these configurations to something noticeable right away e.g. "awesome-project TEST".