I'm trying to unit test following piece of code using pytest: import json from typing import Any, Dict  from confluent_kafka import Consumer   def get_message(config: Dict[str, Any]):     consumer = Consumer(         {             &quot;group.id&quot;: config[&quot;KAFKA_GROUP_ID&quot;],             &quot;bootstrap.servers&quot;: config[&quot;KAFKA_BROKERS&quot;],             &quot;default.topic.config&quot;: {&quot;auto.offset.reset&quot;: &quot;smallest&quot;},         }     )     consumer.subscribe([config[&quot;KAFKA_TOPIC&quot;]])     while True:         collect = consumer.poll()         if collect is None:             continue          try:             message = json.loads(collect.value().decode(&quot;utf-8&quot;))         except json.JSONDecodeError:             continue          return message  But I can't mock subscribe function. I tried: mock_subscribe = MagicMock(return_value='test') monkeypatch.setattr('confluent_kafka.cimpl.Consumer.subscribe', mock_subscribe)  In result I got following error: TypeError: can't set attributes of built-in/extension type  How to mock this function properly?
Ruby can add methods to the Number class and other core types to get effects like this:  1.should_equal(1)   But it seems like Python cannot do this. Is this true? And if so, why? Does it have something to do with the fact that type can't be modified?  Update: Rather than talking about different definitions of monkey patching, I would like to just focus on the example above. I have already concluded that it cannot be done as a few of you have answered. But I would like a more detailed explanation of why it cannot be done, and maybe what feature, if available in Python, would allow this.  To answer some of you: The reason I might want to do this is simply aesthetics/readability.    item.price.should_equal(19.99)   This reads more like English and clearly indicates which is the tested value and which is the expected value, as supposed to:  should_equal(item.price, 19.99)   This concept is what  and some other Ruby frameworks are based on.
Find $f$ if $ f(x)+f\left(\frac{1}{1-x}\right)=x $ Find $f$ if $$ f(x)+f\left(\frac{1}{1-x}\right)=x $$ I think, that I have to find x that $f(x) = f\left(\frac{1}{1-x}\right)$ I've tried to put x which make $x = \frac{1}{1 - x}$, but this equation has no roots in real numbers. How to tell M2Eclipse to install jar file as a maven dependency No more than 10,000 results are visible in search If you make a search for something that returns more than 10,000 items in result. For example, search for  return 161,338 results on MSE. But if you select a page where 10,000+ result should be shown:        In the edge case  shows zero results:        But this is actual for any page where per_page * page_number is more than 10,000.  Though this does not happen for Stack Overflow in English. It looks like all other sites are affected.  Related bug report on ruSO.meta: iPhone Passcode for Powering Off Why, historically, do we multiply matrices as we do? Multiplication of matrices &mdash; taking the dot product of the $i$th row of the first matrix and the $j$th column of the second to yield the $ij$th entry of the product &mdash; is not a very intuitive operation: if you were to ask someone how to mutliply two matrices, he probably would not think of that method. Of course, it turns out to be very useful: matrix multiplication is precisely the operation that represents composition of transformations. But it's not intuitive. So my question is where it came from. Who thought of multiplying matrices in that way, and why? (Was it perhaps multiplication of a matrix and a vector first? If so, who thought of multiplying them in that way, and why?) My question is intact no matter whether matrix multiplication was done this way only after it was used as representation of composition of transformations, or whether, on the contrary, matrix multiplication came first. (Again, I'm not asking about the utility of multiplying matrices as we do: this is clear to me. I'm asking a question about history.) I am trying to take pictures of large rugs. The rug size is about 10mx5m, and I'm  planning to purchase , and Canon 7D Mark II with Canon EF 50MM F/1.2L USM lens, since we need high quality images.  We want to set up a studio to take giga-pixel quality images of the large rugs for museum conservation purposes  Could you please suggest the best way for mounting the camera to the ceiling, and any other recommendations for my camera/lens setup, and required lighting? It will be  an indoor shoot. Just we want to setup a studio to shoot the large rugs. How to prove that if $a\equiv b \pmod{kn}$ then $a^k\equiv b^k \pmod{k^2n}$ Convergence/Divergence of infinite series $\sum_{n=1}^{\infty} \frac{(\sin n+2)^n}{n3^n}$ $$ \sum_{n=1}^{\infty} \frac{(\sin n+2)^n}{n3^n}$$  Does it converge or diverge?   Can we have a rigorous proof that is not probabilistic?   For reference, this question is supposedly a mix of real analysis and calculus. Add Virtualbox Shortcut in Unity Launcher to boot to a VM Prove: If $\gcd(a,b,c)=1$ then there exists $z$ such that $\gcd(az+b,c) = 1$ I can't crack this one.      Prove: If $\gcd(a,b,c)=1$ then there exists $z$ such that $\gcd(az+b,c) = 1$ (the only constraint is that  $a,b,c,z \in \mathbb{Z}$ and $c\neq 0)$ How to simulate data that satisfy specific constraints such as having specific mean and standard deviation? This question is motivated by . But I imagine that it would also be useful in teaching contexts where you want to create a dataset that exactly mirrors an existing published dataset.  I know how to generate random data from a given distribution. So for example, if I read about the results of a study that had:   a mean of 102, a standard deviation of 5.2 , and  a sample size of 72.   I could generate similar data using rnorm in R. For example,   set.seed(1234) x &lt;- rnorm(n=72, mean=102, sd=5.2)   Of course the mean and SD would not be exactly equal to 102 and 5.2 respectively:  round(c(n=length(x), mean=mean(x), sd=sd(x)), 2) ##     n   mean     sd  ## 72.00 100.58   5.25    In general I'm interested in how to simulate data that satisfies a set of constraints. In the above case, the constaints are sample size, mean, and standard deviation. In other cases, there might be additional constraints. For example,    a minimum and a maximum in either the data or the underlying variable might be known. the variable might be known to take on only integer values or only non-negative values. the data might include multiple variables with known inter-correlations.   Questions   In general, how can I simulate data that exactly satisfies a set of constraints? Are there articles written about this? Are there any programs in R that do this? For the sake of example, how could and should I simulate a variable so that it has a specific mean and sd? Chinese Passport Holder Transit in South Korea A Chinese passport holder with a US visa has a flight scheduled from Beijing to Los Angeles in mid-November.  This person wants to go to South Korea for a 3 day conference; the conference is one week prior to the PEK-LAX flight.  If this person buys a round-trip ticket from China to Korea, will the transit visa be sufficient? Or will they need a regular visa?    Extra info:  What if the original ticket were modified to make it ICN-PEK-LAX?  . It says "Holding a confirmed onward flight ticket for departure within 30 days." Would a return ticket to China than a flight to LAX a week later be sufficiently "onward"? When I'm on my mod site I have my diamond dropdown:    But on Meta.SE and other sites, I have the StackBurger:    This doesn't show on my mod site, so I can't switch between sites easily. Let $A$ be a $m \times n$ matrix with entries from some field $F$. Define the determinant rank of $A$ to be the largest possible size of a nonzero minor, i.e. the size of the largest invertible square submatrix of $A$. It is true that the determinant rank is equal to the rank of a matrix, which we define to be the dimension of the row/column space.  It's not difficult to see that $\text{rank} \geq \text{determinant rank}$. If some submatrix of $A$ is invertible, then its columns/rows are linearly indepedent, which implies that the corresponding rows/columns of $A$ are also linearly indepedent.  Is there a nice proof for the converse? How to create old looking/ cracked glass I am looking for old looking cracked glass for a window in a shack scene. I have looked everywhere but can find a tutorial or material or model on this please can someone help me on this thanks How should artwork be setup for T-shirt printing? What does it mean to colour separate the artwork for T-Shirt printing? It is normally suggested to use Pantone colours for T-Shirt printing. Is it the Pantone Coated or the Pantone Uncoated? The Uncoated one has more subtle colours and we can't choose brighter shades if the design requires that. What is more appropriate for printing? Can we use gradients in T-Shirt printing or is it suggested to stick to flat colours only?   The reason for asking if gradients were ok was to use it as an option for this design:    I was considering it an option, as it will be difficult to colour separate since the textures are clip masked inside the lion. Quote unquote (or end-quote), unseparated by the actual quotation Why are there no Pokémon near me? NMI watchdog: BUG: soft lockup - CPU#2 stuck for 23s! [plymouthd:305] I get this error message   NMI watchdog: BUG: soft lockup - CPU#2 stuck for 23s! [plymouthd:305]    on the startup of my system (even with live-cd).  My PC is a dell inspiron 7559 with intel graphic and nvidia.  UPDATE - this issue also happens when attempting to install ubuntu 18.10 using LiveUSB the verb in plural with one company