Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PyCharm unittest error: Provide a qualified name of function, class or a module

How to get rid of this annoying error? I do not understand what it want me to do. This happens when I am trying to run a test Clicking on "Run" follows up with the following Screen Clicking on "Continue Anyway" runs the tests normally. So what should I do in order to stop this window from popping up every time I ran the tests?

Updated: Here is what I've found myself meanwhile: From here

if (targetType == PyRunTargetVariant.PYTHON && !isWellFormed()) {
      throw RuntimeConfigurationError("Provide a qualified name of function, class or a module")
    }

And a function isWellFormed() declaration from here

/**
  * Sanity check for "target" value. Does not resolve target, only check its syntax
  * CUSTOM type is not checked.
  */
 fun TargetWithVariant.isWellFormed() = when (targetVariant) {
   PyRunTargetVariant.PYTHON -> Regex("^[a-zA-Z0-9._]+[a-zA-Z0-9_]$").matches(target ?: "")
   PyRunTargetVariant.PATH -> !VfsUtil.isBadName(target)
   else -> true
 }

Everything looks good with a regex of my test class and method names.

like image 362
Roman Avatar asked Nov 02 '18 14:11

Roman


1 Answers

Ok, this is really weird. I took a good look at a regex and found that it doesn't want any '-' in the target path. So renaming a filename from ads_wrapper-tests.py to ads_wrapper_tests.py solves the problem and the window is not popping up any more.

like image 70
Roman Avatar answered Nov 16 '22 02:11

Roman