Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9140435
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T09:30:57+00:00 2026-06-17T09:30:57+00:00

My goal is to execute a python script (that executs some unittests) via a

  • 0

My goal is to execute a python script (that executs some unittests) via a small *.bat script.
The *.bat script should also receive the exit status of the python script. But it seems that the exit status of the *.py file is not transmitted correctly.

My testit.py:

execute_some_unittests()
   ...
   if success:
       sys.exit(1) 
   else:
       sys.exit(2)
   # End of the script

My test.bat:

python C:\testit.py
echo %ERRORLEVEL%

Depanding on the unittests I run in execute_some_unittests(), running test.bat results in 1, 2 or 0!!! I’m absolutly sure that the code reaches the sys.exit(1) (because i log everything) but nevertheless (depending on what unittests get tested) it goes wrong.

My guess is that executing the unittests is setting some flags which will be merged with the exit code and produce a unix like 16 bit exit code (instead of 8) and that the cmd is somwhat truncating my exit code…

Remarks:

  • The code above is not inside a try, except block
  • Replacing the sys.exit(1) with os._exit(1) does not help

I’m working since 2 days at this problem and will be gratefull for every idea…

I’m using Win7, python 2.6, modules: unittest, doctest, sys, os

Update: was asked for a full working example:

test.py:

import unittest
from scipy.interpolate import interp1d
class Test(unittest.TestCase):
    def test_basic(self):
        self.failUnlessEqual(1, 1)
if __name__ == '__main__':
    suite = unittest.TestLoader().loadTestsFromTestCase(Test)
    unittest.TextTestRunner(verbosity=2).run(suite)
    import sys
    sys.exit(42)

test.bat:

python C:\test.py
echo %ERRORLEVEL%

Result: error level 0 (whithout import scipy.interpolate it would be 42, but scipy is not the only module producing this problem)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T09:30:58+00:00Added an answer on June 17, 2026 at 9:30 am

    This is a known error in the scipy module. See Issue “import scipy.sparse.sparsetools causes consistent exit code 0“.

    This issue seems still being open…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My goal is ultimately to execute a python script that manipulates values in my
The goal is to implement a web application that can execute methods of .class
My goal is to have an AsyncTask that can execute multiple times (one task
I have a python script that is intended to run on my local machine
I have a .bat that sets up an environment which allows users to execute
Is there a Maven phase or goal to simply execute the main method of
Goal is to make a dialog that appears on menu_key pressed, but it keeps
Goal: Produce an Excel document with information from 3 associated models that is similar
The Goal: Execute logic on each element in array. Wait X ms in between
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-install-plugin:2.3.1:install (default-install) on project ecommerce-web: Failed to install metadata

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.