Ignore Sphinx autodoc warnings for rtype values - python-sphinx

Right now autodoc seems to throw warnings for any rtype value that is not just an object type (a class instance, int, list, dictionary, etc). So a return value such as "list of tuples" will throw a warning. Is there any way to ignore these warnings (either individually or on the whole)? I don't want to ignore the whole file, just those specific warnings.
An example of this warning might be something like:
/path/to/code.py:docstring of path.to.code.method:: WARNING: py:class reference target not found: list of tuples
And in some cases, I'm seeing errors for objects that I know are legit classes imported in the code like:
/path/to/code.py:docstring of path.to.code.method:: WARNING: py:class reference target not found: Response
In that example, "Response" is part of rest_framework.response, so it's a pretty commonly used class object.
These warnings happen anytime I do a fresh make docs. It's not clear to be that it can be reproduced in another environment.

The solution here was that the classes in question were not in a toctree, so were not part of the docs. Basically, autodocs wants to be able to link to classes mentioned in type variables. If it can't do that, it will throw an error saying "I have no idea what "Response" is (or whatever the class happens to be that you return). Not an error, because it assumed you're right, but a warning that it can't find it. So the solution here was to create an index.rst that included the class, then a Response.rst (for example) including the relative path to the class. Below is an example of this process. It assumes that Response is in a rest.py.
error: /path/to/code.py:docstring of the.code.rest.GetAccount.get:: WARNING: py:class reference target not found: Response
In my case, this needed the following:
add a line item for response to modules/code/rest.rst
add response.rst in the same directory
include the line `.. automodule:: code.rest.Response
Then delete and rebuild docs and it should be good to go.

Related

What to put in rspec's expect for a globally available object?

I am writing a custom matcher for my logging output, mostly so that I can customize the error output to be more readable and helpful.
The thing being examined for the test is the array returned by LoggingSpecHelper.log_events, a module class method (i.e. not a module instance method). Therefore, it is available without the need for it to be passed as a parameter.
LoggingSpecHelper.log_events is kind of long to specify in each expectation, and anyway I'd prefer to hide that implementation detail from the caller, in case that implementation changes. That leads to my using expect(:logging), where :logging is a dummy value which has no meaning and is not examined. This, however, is awkward and confusing, leaving the reader scratching their head thinking "he's examining a symbol?"
Here is an example of how it is currently called; in this case I'm looking to see if a fatal error occurs in the log that contains 'something is misconfigured' (not a real production message):
expect(:logging).to have_log_output_match(:fatal, 'something is misconfigured')
The long form of this, and what is happening in the matcher, is below, but if I do this instead of calling the matcher, I don't get to see what is in the log if an error occurs (the matcher includes log content in the failure message):
expect(LoggingSpecHelper.log_events.count do |event|
event.level == :fatal && /something is misconfigured/.match?(event.message)
end).to be == 1
How would you suggest I handle this? I don't think shared examples are what I want here because this log expectation might not be the only expectation in the example.
As an aside, I should probably rename the matcher so that it is clear that I am testing for 1 and not >=1 occurrences.

cygwin warning: COMDAT symbol does not match section name

I am using g++ (5.4.0) on cygwin, to compile and link some cpp files. Compilation goes through fine, but during linking I get many errors like:
lib.a: warning: COMDAT symbol '.pdata$_ZnwmPv' does not match section name '.pdata'
lib.a: warning: COMDAT symbol '.xdata$_ZnwmPv' does not match section name '.xdata'
I am not able to figure out what this message means, nor how to fix the problem. I tried a google search, and got this link: https://sourceware.org/bugzilla/show_bug.cgi?id=15041
It seems to indicate that the problem is fixed and checked in, way back in 2013.
So does my error message mean that this fix is not available in the gcc of cygwin? Or is there something else that I need to do to fix/bypass this problem?
Also, is there any way I can get more details on what exactly is the mismatch? That may indicate what I need to fix in my code.
Some more details : The warning occurs only in cygwin, and not in ubuntu, so I have also added the cygwin tag to this question and also mentioned cygwin in the question. And it happens only when I add the following code to my classes. If the addObject2 method is deleted, and the private member _obj2Array is made public and its code is moved to the application, then the warning goes away.
myObject1.h:
class myObject1: public myParent {
... // constructors, etc
vector<myObject2*> _obj2Array;
public:
void addObject2(myObject2* obj2);
}
myObject1.cpp:
void myObject1::addObject2(myObject2* obj2) {
_obj2Array.push_back(obj2);
}

Drupal, entity_metadata_wrappers and debugging

For handling entities in Drupal I'm using Entity Metadata Wrappers (the "Drupal way").
It's really easy to start coding and see all the advantages it has... except when you get a fatal error and you are not clear where it comes from.
This is what the database log shows:
EntityMetadataWrapperException: Unknown data property
field_whatever. at EntityStructureWrapper->getPropertyInfo()
(line 335 of
/var/www/html/sites/all/modules/entity/includes/entity.wrapper.inc).
Sadly, many times that "field_whatever" is "nid", "uid" or some very common property, so it's name is spread all over my code, which makes me difficult to get to the origin of the error.
I'm currently doing this:
Write a tiny piece of code and then run to see if something fails.
Using getPropertyInfo when handling entities with "not so common" fields.
Loosing hair.
What is worst is that sometimes the error does not appear when you are coding, but a week later. So it could be anywhere...
Is there any way of handling entity metadata wrapper errors better? Can I get better information in the database log and not just a line? A backtrace maybe?
Thanks.
Well, having the devel module active (just to see the nice krumo message) we can do something like this inside our module:
<?php
set_exception_handler('exception_with_trace');
function exception_with_trace($e)
{
dpm($e->getTrace());
}
That will return the backtrace error of the exception thrown by the entity metadata handler on the next page load (some page in your site where everything is running fine).
Also you can set the exception handler exclusively and more elegant just for some pages or some users with some role... or when some parameter in the url is met, or when in some state of your Drupal site is met (ex. when a bool persistent variable 'exception_with_trace' is true). Even, under certain conditions and control, you can use it in production too.
If the site does not work "at all" you can include it in your settings.php file, but instead of printing the trace, you must write the trace to a file and watch the trace in a different context (not Drupal but some php file).
If exceptions are too long and are causing memory problems then getting the trace as string is also possible. See http://php.net/manual/es/exception.gettraceasstring.php
Hope that helps.

HP-UFT object not found in object repository error

Getting the following error while executing script:
WebList object was not found in the Object Repository.
Check the Object Repository to confirm that the object exists or to find the correct name for the object.
Line (1221): "objParent.WebList(vstrObjectName).select vstrValue".
I understand, it shouldn't be as simple as the object isn't available in the repository but in in case- Try to use 'Locate in repository'
It looks like Line (1221) is trying to access a WebList object by name, but the name is stored in a variable; it is not a string literal in the code.
There might be 3 different things going on here.
1) if you were attempting to use Descriptive Programming, then it sounds like the contents of vstrObjectName didn't include the ":=" symbol that would make QTP believe the string is a description... So, QTP thinks the string stored in vstrObjectName must be the name of an object in the Object Repository.
I would like to guess that you were trying to use descriptive programming, since (based on the fact that the parent, and the parameter are also both contained in variables) it looks like you are avoiding using any string literals in that line.
2) If you were attempting to control an object with a name from the Object repository, then either the string contained in vstrObjectName didn't contain a valid object name (that belongs to objParent), or
3) the object refered to by objParent isn't the one you were expecting.
In any of these cases, if it were me, the first thing I would do is add a print statement before line 1221 as:
Print "vstrObjectName:'" & vstrObjectName & "'"
...and run it again. That should show the string that you were referencing. I would guess that the resulting output line is not what you expected.
Another thing to check is to make sure that the action or function that contains that line is executed from within an action that contains that named object in it's OR scope. (i.e. open the action and hit CTRL-R, it shows the combined OR that is visible to that action). If the line is in a function library, and it gets called from an action that doesn't have the object in it's local OR, or an attached shared OR, then you will get the same error. This kind of problem is very easy to cause if you use multiple actions, and the action containing the call to the function that contains your line (line 1221) doesn't actually have that object available to it due to it's OR scope.
To answer the question you asked - how to add object into the OR - you could use several methods - recording, guispy's add to OR button, manually add from the OR screen, etc... but in the end, you need that object in the OR to have a name that matches whatever is in vstrObjectName.
Some potential examples where an object can be selected:
Dynamically change the object based on the name of the object in the object repository:(must exist in the repository)
Dim objectname
objectname = "SAP Work Manager"
msgbox WpfWindow(objectname).Exist
Select an object that does not exist in the Object repository, by its properties:
WpfWindow("text:=SAPWorkManager").Exist
Example page of UFT tips

QTP - if object exists in object repository

In QTP is there any way in the code to check to see if a specific object exists in the object repository. I have tried the following code:
If JavaWindow(className).JavaDialog(dialogName).Exist Then
doThisStuff
Else
doThisStuffInstead
End If
But from what I have gleamed from the Internets, this is similar to a isVisible method, only resulting in true if the specified object is currently visible. When I use the above code I receive a "JavaDialog object was not found in the Object Repository." Is there a method or any way to prevent this very error and check to see if the object does indeed exist?
Thank you for your time
I'm not sure what you're trying to accomplish here, one typically knows if an object exists in the object repository before using it. The doubt is usually whether there is a corresponding control in the AUT (Application Under Test).
If you really face the situation that sometimes the object is in the repository and sometimes it isn't (I can think of several ways for this to happen but none of them make much sense) then you can use VBScript's error handling mechanism.
On Error Resume Next ' Turn off error handling
' Just check if object is in repository, there's no need to do anything with it
Dim Exists: Exists=JavaWindow(className).JavaDialog(dialogName).Exist
If Err.Number <> 0 Then
doThisStuff 'Exists is still empty
Else
doThisStuffInstead ' Exists is properly set
End If
On Error Goto 0 ' Resume regular error handling
So, from the error you get, either the dialog that appears is different from the one you've stored in the repository or you don't have it there.
Have you checked it is really present in the Repository? You can try to just locate this element button.
Using the method of "if object not in the repository - skip the step" is not really a good idea. 1. Why would you want to skip the test/part of the test if the object was not saved in the repository?
2. If it's not there, so you need to make sure to store it.
I would assume that this "missing" object might have some values by which it's matched to the object from the repository different from test to test. You can tune the "matching" mechanism by manually setting the values by which you want QTP to locate it.

Resources