w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML Categories
Test Impact Analysis & Ms build execute only Impacted Test
The following thing worked for me. Microsoft.TeamFoundation.TestImpact http://scrumdod.blogspot.in/2011/03/tfs-2010-build-only-run-impacted-tests.html

Categories : Tfs

Running maven test on a specific class - [ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.10:test
For those that have the same issue. Its my blunder (maybe). The @Test annotated method has no access specifier. I just use void method(). I added public and it started working! Thanks @user2507946. Running from IDE help solve the issue.

Categories : Maven

Execute test method in junit4
You are creating 2 chrome instances in your code: First when your @BeforeClass @BeforeClass public static void start()throws Exception { System.setProperty("webdriver.chrome.driver", "E:/Selenium/lib/chromedriver.exe"); driver = new ChromeDriver(); And the again when you create LoginPage object. public class LoginPage{ WebDriver driver = new ChromeDriver(); So depending on your need, you have to remove one of these. I cant really see where the user and pass variables are assigned, but assuming they are webelements you probably get them from driver. So if you don't initiate driver in LoginPage you get nullpointer indeed. If you still need to start the driver in your @BeforeClass and you want to use the same driver instance in your code, you could get a getter for this.

Categories : Java

How to execute a Selenium test in Java
A good way to run Selenium Java code in Eclipse is to run them as JUnit tests. 1. Create a Maven Project in your Eclipse.If you haven't done this before, see: How to install/integrate Maven with Eclipse How to create a simple Maven project 2. Add the following dependencies to your pom.xml file: <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.7</version> <scope>test</scope> </dependency> <dependency> <groupId>org.seleniumhq.selenium</groupId> <artifactId>selenium-java</artifactId> <version>2.25.0</version> </dependency>    <dependency> <groupId>org.seleniumhq.seleni

Categories : Java

Execute test with vstest.console and parameters
I haven't seen any commands that make this happen. Official command line documentation: http://msdn.microsoft.com/en-us/library/vstudio/jj155796.aspx You could author your tests to load from an external file (xml, ini, etc.) or source (db) which would simulate this. If the application were to generate the data, the test methods could load it and use the data during execution. I've been doing something similar where I generate a setting file containing various information for a web application to be tested, it then launches the test and the tests load from that data file and use the settings for parameters.

Categories : C#

Can SBT execute compiled tests with `sbt test` or similar?
Something very similar to this was done for the Functional Programming principles in Scala with Martin Odersky at the EPFL. They used two sets of tests, one which were published with the code, which the students could run while coding (using sbt test), and one set which lived on the server, which were run when the code was published. The second (server) was the one which produced the report and gave the grade. This was fed back using the coursera site, but you can always send a mail or something. The server wasn't done synchronously, it was done as part of a batch. The code was also graded based for various style points using Scalastyle. Don't base your grades on the code which is executed on the student machines. This isn't secure. Yes, you can do this without using a plugin, you just

Categories : Java

Play2: How to do execute piece of code before each test using specs2
Just extend from this trait org.specs2.mutable.BeforeAfter, it comes with before and after methods, implement them, here is a link to documentation docs

Categories : Scala

Howto have maven surefire execute JUnit and TestNG test properly?
I haven't done it myself, but you could try to configure two different executions of the maven-surefire-plugin and configure one of these executions to only run JUnit tests and the other to only run testNG tests. To differentiate between JUnit und testNG tests you should either put the tests in different directories or use a distinguishable name scheme and configure each of the executions with suitable inclusion and exclusion patterns. In theory this should work :)

Categories : Java

Python unittest: test a test
A subclass of unittest.TestCase is like any other class, hence you can write a unittest.TestCase that checks whether its methods work as they should. In particular you should build sets of pairs of numbers that should pass and fail the test, and then call the assertSFAlmostEqual method with these inputs and see whether the test pass or fail. The answer you linked does this, even though it's probably a more complicated solution than what's required. For example, I'd simply have written something like: import unittest class MyBaseTestCase(unittest.TestCase): def assertSpec(self, thing): assert thing == 123 class TestMyTest(MyBaseTestCase): def test_failures(self): self.assertRaises(AssertionError, self.assertSpec, 121) def test_successes(self): sel

Categories : Python

Can't execute python script from php
Your problem is this: When launching the php script through the console, you are launching php with the permissions of your current user. When a process is executed through opening it in the browser, it will have the permissions of the user of your web-server-process. Your group permissions will have to be 7 no matter what. Either change the python scripts permissions to 777 (read-write-execute for everybody) or change it to 770 and make sure that your web-servers user is inside the group set to the file.

Categories : PHP

Python: Why does this code execute?
This is the output I get: 1 2 2 1 3 0 4 -1 5 -2 6 -3 7 -4 8 -5 9 -6 10 -7 Your question as to why it runs. Your outer most conditional is a while loop, which is true upon the first execution, however it runs right into a nested for loop. When this happens the while, will not be checked until the for loop finishes its first execution (which is why p = -7). What you want is this: p = 2 for i in range(10): if p <= 0: break print i+1 , p p-=1 which gives output: 1 2 2 1

Categories : Python

Nunit loads all test Test data for all the test before the test gets executed
I think that's by design. NUnit is designed to clean up the environment before any test, to generate same conditions for any test independent their execution order. If Test A would change the XDocument, Test B would be run with that changes. That might led to indeterminate test results. If Test B expects changes made from Test A, then your tests are not fully isolated, that's a bad practice. If you wan't to change that behaviour, implement a lazy field and load the test data only on first access. You can increase performance if you know that you are not changing data in any of your tests, but pay attention. private static Lazy<IEnumerable> testData = new Lazy<IEnumerable>(GetExample); private static IEnumerable GetExample() { var doc = XDocument.Load("Example.xml");

Categories : Xml

Python: rasing from except causes finally to execute?
finally is executed no matter the try block succeeds or the except block is run due to exceptions! even if your except block raises an exception the new exception will be handled by another try catch handler but after executing the finally block, instead of forming a recursive loop: try: try: [...] except: raise Exception([...]) #this is line number xyz finally: [code] except: [...] #this code will be running after line number xyz

Categories : Python

execute main through if condition in python
Make it an independent function. def run_main(): .... if __name__ == "__main__": run_main() And you can call run_main() from another file.

Categories : Python

Execute python script in localhost
Google App Engine SDK for Python includes a local web server application that simulates the App Engine environment. It allows for instant server script changes by just saving the file and refreshing the browser. The development tutorial is here Once you have your web site working locally, it is easy to deploy it live on Google's App Engine servers.

Categories : Python

How to execute commands through pipe in Python?
Piping is a shell function. Therefore your Popen call needs shell=True on it. Otherwise your | wc is going to be passed to find, which won't know what to do with it (and is probably sending an error to that effect into err... which you're not printing). But why shell out at all? Just do all that stuff in Python (e.g. os.walk to replace find) It'll be easier to read and maintain. Something like: import os, re for dirpath, dirnames, filenames in os.walk(rootpath): for filename in filenames: if filename.endswith(".cc"): with open(os.path.join(dirpath, filename)) as infile: text = infile.read() chars = len(text) lines = sum(1 for x in re.finditer(r" ", text)) lines += not text.endswith(" ") # count last

Categories : Python

Execute python in a php script using shell_exec()
I think kernel not able to find the path for python where it is installed..if you can do echo $PATH..it will show all the paths where to be search a command if given add your python part there and then it may work or you can give absolute path(other than /usr/bin/) see if it works..I need to test it too.

Categories : PHP

Execute .sql schema in psycopg2 in Python
You can just use execute: with self.connection as cursor: cursor.execute(open("schema.sql", "r").read()) though you may want to set psycopg2 to autocommit mode first so you can use the script's own transaction management. It'd be nice if psycopg2 offered a smarter mode where it read the file in a statement-at-a-time and sent it to the DB, but at present there's no such mode as far as I know. It'd need a fairly solid parser to do it correctly when faced with $$ quoting (and its $delimiter$ variant where the deimiter may be any identifier), standard_conforming_strings, nested function bodies, etc. Note that this will not work with: anything containing psql backslash commands COPY .. FROM STDIN ... and therefore won't work with dumps from pg_dump

Categories : Python

How to execute awk command by python code
While I agree that this is actually best done in Python, rather than invoking awk. If you really need to do this, then the actual error is with your awk. #!/usr/bin/env python import subprocess as sp args = ["awk", r'{OFS=" "; print $2,$4,$5,$6}', "B3LYPD.txt"] p = sp.Popen(args, stdin = sp.PIPE, stdout = sp.PIPE, stderr = sp.PIPE ) print(p.readline()) # will give you the first line of the awk output Edit: Fixed missing quote.

Categories : Python

crontab doesn't execute my python script
First, you have an odd indentation in the line with if __name__ ==... - guess you should check it in your script. Then, make sure with what current directory your script runs, AFAIK it is your $HOME - this is where the file would appear.

Categories : Python

execute cat command in subprocess,Popen() of python
The problem is that you're passing the command as multiple args. You need to pass them as a list or a tuple. Like: subp.Popen([ 'egrep','list_of_IDs','/home/bimlesh/python/result.log' ], stdout=subp.PIPE,stderr=subp.PIPE,shell=True)

Categories : Python

In Python, how do you execute objects that are functions from a list?
Make all of them lists and then iterate over the list executing each in turn. for actionVal,actionDesc,actionFunctions in validActions: if ctx["newAction"] == actionVal: for actionFunction in actionFunctions: actionFunction()

Categories : Python

Execute python script using urllib2 from PHP behind Proxy
You could try passing explicit proxy settings to your Python script to see if that clears up the problem for you. I recently wrote a script that allows you to set proxy settings with command line arguments that might be useful for this case. The important parts of the script are below: # Import the required libraries from urllib import urlencode from urllib2 import Request, urlopen, URLError, ProxyHandler, build_opener, install_opener import argparse # Set up our argument parser parser = argparse.ArgumentParser(description='Does stuff through a proxy') parser.add_argument('webAddr', type=str, help='Web address of target server') parser.add_argument('--proxServ', metavar='SERV', type=str, help='Web address of proxy server, i.e. http://proxy.server.com:80') parser.add_argument('--proxType'

Categories : PHP

crontab: python script being run but does not execute OS Commands
Two things: Your cd will set the directory for that subprocess, which immediately exits: subprocess.call(["cd", "/home/atweb/Documents/opengrok"]) In other words, it's a wasted step. The next subprocess doesn't know anything about the previous one's environment: subprocess.call(["./stop_website"]) ...so it won't be able to run. If you want all of your programs to run in that directory, use: os.chdir("/home/atweb/Documents/opengrok") before any of the subprocess.call() lines.

Categories : Python

How to execute code when a Python script is closed out?
import MySQLdb con = MySQLdb.connect(...) cursor = con.cursor() try: # do stuff with your DB finally: con.close() The finally clause is executed on success as well as on error (exception). If you hit Ctrl-C, you get a KeyboardInterrupt exception.

Categories : Python

Execute Shell Script from python with variable
Like this ? subprocess.call(['test.sh', str(domid)]) Documentation is available on the python website

Categories : Python

Execute R script with python subprocess.call
Using commandArgs like this: args <- commandArgs(trailingOnly = TRUE) arg1 <- args[1] arg2 <- args[2] [...your code...] Also make sure that the Rscript executable is in your PATH.

Categories : Python

Execute and wait for results C program and Python script
Use subprocess module. import os import signal import subprocess import sys params = [...] for param for params: proc = subprocess.Popen(['/path/to/CProg', param.., param..]) subprocess.call([sys.executable, 'B.py', param.., param...]) os.kill(proc.pid, signal.SIGINT) proc.wait()

Categories : Python

execute an specific method of the instances in a list in python
operator.methodcaller() will give you a function that you can use for this. map(operator.methodcaller('method_name'), sequence)

Categories : Python

Execute process from the windows command line in Python
By trying your code it prints out PreprocessedTufts8199PLAIN.txt.xml file name. I'm not sure if the .txt.xml extension was the desired result. If your file has only .xml extension, then you're not stripping away the original .txt header. Try to change this line: outFile = file(inFile[(str(inFile).rfind('\'))+1:] + '.xml') Into this code: fnameext = inFile[(str(inFile).rfind('\'))+1:] fname,fext = os.path.splitext(fnameext) xmlfname = fname + '.xml' xmlfpath = os.path.join(".", xmlfname) print "xmlfname:", xmlfname, " xmlfpath:", xmlfpath print "current working directory:", os.getcwd() outFile = open(xmlfpath, "r") Answer for extension stripping.

Categories : Python

Use value from javascript on html page to execute python script
Here is a simple Python script that pipes the output of a locally executed command (dir on a Windows computer in this case) via a web request (using the excellent web.py library): import web from subprocess import check_output urls = ( '/', 'index' ) app = web.application(urls, globals()) class index: def GET(self): return '<pre>'+check_output('dir', shell=True)+'</pre>' if __name__ == "__main__": app.run()

Categories : Python

jenkins wouldn't execute python script correctly
If you are running Jenkins as a Windows service, by default it runs as user Local System. Did you check the box titled "Allow service to interact with desktop"?. If that does not help you may have to set the service to log on as an actual user, instead of Local System. This is a common problem with running any process with a GUI from Jenkins.

Categories : Python

how to execute Python 3.3 script in Spyder console with variables?
You need to go Run > Configure (or hit F6) and in the dialog that it appears you need to check 'Command line options' and write (for example) there 1 2 3 After closing this dialog and hitting F5, you'll see the output you are expecting. Note: Please remember that these command line options are saved between Spyder restarts as part of the file run config, so if you want to change them, you need to hit F6 again.

Categories : Python

Cannot execute Python script in Apache although permissions seem fine
SELinux is preventing you from executing the script as httpd. You need to change the file context on the CGI script to httpd_user_script_exec_t in order to execute it. See the httpd_selinux(8) and chcon(1) man pages for details.

Categories : Python

Execute a Python script post install using distutils / setuptools
The way to address these deficiences is: Get the full path to the Python interpreter executing setup.py from sys.executable. Classes inheriting from distutils.cmd.Command (such as distutils.command.install.install which we use here) implement the execute method, which executes a given function in a "safe way" i.e. respecting the dry-run flag. Note however that the --dry-run option is currently broken and does not work as intended anyway. I ended up with the following solution: import os, sys from distutils.core import setup from distutils.command.install import install as _install def _post_install(dir): from subprocess import call call([sys.executable, 'scriptname.py'], cwd=os.path.join(dir, 'packagename')) class install(_install): def run(self): _in

Categories : Python

Using ProcessBuilder to execute a python script with command line options
Just give them as separate strings in the array, instead of combining the last two into "val_31 val_32": String[] command = {"script.py", "run", "-arg1", "val1", "-arg2", "val2" , "-arg3" , "val_31", "val_32", }; Otherwise it will escape the space in between val_31 and val_32 because you are telling it that they're a single parameter. Incidentally, you can also use the varargs constructor and skip having to create an array, if you want: ProcessBuilder probuilder = new ProcessBuilder( "script.py", "run", "-arg1", "val1", "-arg2", "val2" , "-arg3" , "val_31", "val_32");

Categories : Java

Python execute code only if for loop did not begin iteration (with generator)?
I can't think of a better way than updating a boolean inside the for loop. any_results = False for x in g: any_results = True print x if not any_results: print 'Done'

Categories : Python

VS2012: Clear the test results in Test Explorer when re-running a test that previously failed
You cant do that. Instead you can filter which test are shown to you, if that suits your needs. You can find more information about test here: http://msdn.microsoft.com/en-us/library/hh270865.aspx

Categories : Unit Testing

Grails Spock integration test redirectedUrl different between localhost test-app and build server test-app
I've also just experienced this same issue, and it seems that it comes down to the test framework extracting the controller name from the the name of the testing class. The convention is that the test class is named <controller name>ControllerSpec In the above case, the test class should be named PriceTierControllerSpec so that the test framework will successfully resolve the controller to PriceTeir. Naming the class according to these guidelines seems to fix this problem. Further reference can be found here: https://jira.grails.org/browse/GRAILS-10962

Categories : Grails

How to test single test modules in intellij in maven project having test dependency?
Got my answer there : http://youtrack.jetbrains.com/issue/IDEA-112978 That's because a run configuration is created by template. And that template has default setting to pick classes across module dependencies. For me in 132.46 the following helps: 1. Open Run Configuration dialog, Defaults section. 2. Find respective template. I tried JUnit. 3. "Test kind" combo, select All in package. 4. Set "In single module". 5. Apply to save the template. After that delete created configurations and repeat "Run All tests". It picks only classes from current module for me. The possible improvement in IDEA is to modify these defaults specially for Maven-based projects. Rather specific change...

Categories : Maven



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.